code: def _finalize(self):
          
          if self.status in ['running', 'halt']:
              if self.verbose > 0:
                  print_('\nSampling finished normally.')
              self.status = 'ready'
  
          self.save_state()
          self.db._finalize()
docs: Reset the status and tell the database to finalize the traces.