terminate application upon closing of the main window