smell your fingers. if they smell like gas you shut it off.
or shut the gas off and let the engine stall. but then you have to remember to turn the key off. but then it is easier to deal with a dead battery than a dry fuel tank ?????
or only keep a gallon or so of gas in the tank.