def _close_window(self, confirm_discard, wait_for_execution):
        if global_settings.main_menu_mode and self.window.is_active():
            main_menu.window_deactivated(self)

        application.window_closed(self)
        self.window.destroy()

        # Need to break the circular references back through the actions
        self.action_group = None
        self.ui_manager = None

        self.notebook.close()

        gc_at_idle()
    def _close_editor(self, editor):
        if not editor.confirm_discard():
            return

        if not editor.wait_for_execution():
            return

        if editor == self.current_editor:
            # Either we'll switch page and a new editor will be set, or we have no pages left
            self.current_editor = None

        if editor == self.__initial_editor:
            self.__initial_editor = None

        self.editors.remove(editor)
        editor.widget._notebook_window_editor = None
        editor.destroy()
        self.__update_title()
        self._update_open_files()
        self.update_sensitivity()

        gc_at_idle()
    def _close_editor(self, editor):
        if not editor.confirm_discard():
            return

        if not editor.wait_for_execution():
            return

        if editor == self.current_editor:
            # Either we'll switch page and a new editor will be set, or we have no pages left
            self.current_editor = None

        if editor == self.__initial_editor:
            self.__initial_editor = None

        self.editors.remove(editor)
        editor.widget._notebook_window_editor = None
        editor.destroy()
        self.__update_title()
        self._update_open_files()
        self.update_sensitivity()

        gc_at_idle()