code: def stop_workers(self, clean):
          
          with executor_lock:
              self.executor.shutdown(clean)
              del self.executor
          with self.worker_lock:
              if clean:
                  self.pool.close()
              else:
                  self.pool.terminate()
              self.pool.join()
              del self.pool
              for x in self.events.values():
                  x.event.cancel()
              self.events.clear()
docs: Stop workers and deferred events.