'Exit tasks'

def closing(self, cancelable=False):

    if (self.already_closed or self.is_starting_up):
        return True
    if (cancelable and CONF.get('main', 'prompt_on_exit')):
        reply = QMessageBox.critical(self, 'Spyder', 'Do    you    really    want    to    exit?', QMessageBox.Yes, QMessageBox.No)
        if (reply == QMessageBox.No):
            return False
    prefix = ('window' + '/')
    self.save_current_window_settings(prefix)
    if (CONF.get('main', 'single_instance') and self.open_files_server):
        self.open_files_server.close()
    for plugin in self.thirdparty_plugins:
        if (not plugin.closing_plugin(cancelable)):
            return False
    for widget in self.widgetlist:
        if (not widget.closing_plugin(cancelable)):
            return False
    self.dialog_manager.close_all()
    if self.toolbars_visible:
        self.save_visible_toolbars()
    self.already_closed = True
    return True
