There are two situations for stopping the motor. First, when STOP is pressed, X1 ON. PLS instruction will be executed and M0 will be ON for one scan cycle. RST instruction will thus be executed, and Y0 will be reset to stop pumping. Second, when the water in the container is empty. X2 will be OFF and PLS instruction will be executed to trigger M0 for resetting Yo. In this case, the pump motor will stop pumping as well