If you want to avoid this, you can go inside and request a specific dollar amount, and they'll charge exactly that. (And the pump will shut off at the right moment.)
I guess it would be nice to have a way to request a gallon or dollar amount at the pump, but I've never seen a pump able to do that.