waiting on a keypress to stop in the main function