code: def close(self):
          
          with self.lock:
              if self.is_closed:
                  return
              self.is_closed = True
  
          log.debug("Closing connection (%s) to %s", id(self), self.endpoint)
          reactor.callFromThread(self.connector.disconnect)
          log.debug("Closed socket to %s", self.endpoint)
  
          if not self.is_defunct:
              self.error_all_requests(
                  ConnectionShutdown("Connection to %s was closed" % self.endpoint))
              # don't leave in-progress operations hanging
              self.connected_event.set()
docs: Disconnect and error-out all requests.