code: def closing_plugin(self, cancelable=False):
          
          self.dialog_manager.close_all()
          self.shell.exit_interpreter()
          return True
docs: Perform actions before parent main window is closed