There are a few ways to do it. Obviously redundant float valves are the one option, but this could be unsightly in a nice tank. I use these floats from autotopoff.com
. It simply a relay that cuts off power to the water fill solenoid.
I also use a normally closed solenoid, meaning that it needs to be energized to open. Lost power, solenoid (valve) closes down.
In addition, I also put this entire thing on a timer and set the timer to just about the amount of time it take to fill. I had this down pretty tight. This way, if the float for some reason stuck (which it never has) the timer will cut the power to the solenoid.