code: def closeEvent(self, event):
          
          max_dataset_history = self.value('max_dataset_history')
          keep_recent_datasets(max_dataset_history, self.info)
  
          settings.setValue('window/geometry', self.saveGeometry())
          settings.setValue('window/state', self.saveState())
  
          event.accept()
docs: save the name of the last open dataset.