code: def closing_plugin(self, cancelable=False):
          
          for cl in self.clients:
              cl.close()
          self.set_option('recent_notebooks', self.recent_notebooks)
          return True
docs: Perform actions before parent main window is closed.