'Stop accepting connections on this port.
This will shut down my socket and call self.connectionLost().
It returns a deferred which will fire successfully when the
port is actually closed.'

def loseConnection(self, connDone=failure.Failure(main.CONNECTION_DONE)):

    self.disconnecting = True
    if self.connected:
        self.deferred = defer.Deferred()
        self.reactor.callLater(0, self.connectionLost, connDone)
        return self.deferred
