Properly stop the user closing the program.