code: def close_window(self):
          
          if self.undocked_window is not None:
              self.undocked_window.close()
              self.undocked_window = None
  
              # Oddly, these actions can appear disabled after the Dock
              # action is pressed
              self.undock_action.setDisabled(False)
              self.close_plugin_action.setDisabled(False)
docs: Close QMainWindow instance that contains this plugin.