Quit main loop when window is closed