There is a small hole at the tip of the nozzle, it's connected to a pump that pulls air from said hole out of your gas tank.  Once this becomes fluid instead of air the pump stops.  This is also why depending on the angle you place the nozzle in it sometimes kicks off every few seconds.