Zeno's Toilet: Toilet fill valve cranky about shutoff
There are several potential causes


It might just need lubrication.  Try greasing things up and see if that helps.
The float itself might be bad.  Try replacing that (they're quite cheap).
You could have a flapper or stopper that is old, which would make it sometimes not align properly to shut off the water flow.  This is easy enough to test, just smear the edges with vaseline and—if the flapper/stopper is the problem—the problem will go away for a while.  It's not a permanent fix, but it'll last long enough to get a replacement in there.


Great title, by the way