Main loop and exit on keypress