Added function for exiting a game loop.