Added support for quitting by clicking the close button.