fixed demo -> (other) mode race condition

When switching away from the 'demo' mode there is
a delay since the daemon must finish its current demonstration
before proceeding.  Therefore if the the PHP code sets the
valves to off in the 'off' mode they may get turned back
on by the demo program before it is done.  To fix this the
demo program now turns off the valves when it is finished.