Stop Command

I want to get out of the do while loop once either I type on or off on the serial monitor.