Moved game exiting into its own function.