The water level is controlled by a pressure switch which is usually located behind the load level selector knob on the control panel on top loader washers. It has a small plastic hose attached to it that runs to the wash tub. This air hose is crucial in determining what level the switch turns off by sensing the pressure difference as the water level rises in the wash tub. The switch also has an electrical connection. On front loader washers, the pressure switch is located along the cabinet interior. Maytag Neptune washers have a pressure switch along side the wash tub. Since you posted no brand name or model number it makes it difficult to determine how your washer is configured.
If the pressure switch fails, the washer will continue to fill until it overflows. A simple problem that commonly occurs, that can "appear" to be a major problem, is the air hose coming off the pressure switch. This will cause the same symptoms you describe and can take minutes to correct. The following link explains:
http://www.fixya.com/support/r762094-washer_overflows
Check the entire length of the air hose and make sure it is attached to the pressure switch and the hose has no slits, cuts or kinks in it. This can also cause the switch to fail. Take your electrical connections and check the contacts to make sure they are clean. If all preliminary steps do not solve your problem, replace your pressure switch.
If you have questions, please let me know. I hope this helps you.