Closing the main window now correctly exits the process