code: def close(self):
          
          # Give time to flush data if debug was on
          if self.debug:
              time.sleep(10)
  
          # Terminate workers
          for host in self.workers:
              host.close()
  
          # Terminate the brokers
          for broker in self.brokers:
              try:
                  broker.close()
              except AttributeError:
                  # Broker was not started (probably mislaunched)
                  pass
  
          scoop.logger.info('Finished cleaning spawned subprocesses.')
docs: Subprocess cleanup.