Better way than exit(0)?
What you need to do is learn what a finite state machine (FSM) is.

An FSM is a way of having the Arduino in one of a finite number of states, such as "light flashing", or "letting water in", etc.

I have written a reasonable (IMHO) tutorial here: https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/