The water line(s) attaches to the machine where it has a valve that opens when the program calls for water. The flow is halted when a diaphragm switch detects that the water has risen to the required level. The program mechanism provides electricity to the valve via the diaphragm switch and once the level is high enough the latter breaks the circuit so the valve no longer has power to stay open and it springs back shut. The water valve operates on a solenoid principle, the diaphragm switch operates on the pressure of air in a tube from the bottom of the washing machine (open end is in water) - the pressure rises with the level of water and eventually the diaphragm presses the switch into an off position (open circuit).