Game now correctly terminates after closing the window.