'Close this connection after writing all pending data.
If TLS has been negotiated, perform a TLS shutdown.'

def loseConnection(self):

    if self.TLS:
        if (self.connected and (not self.disconnecting)):
            self.protocol.loseConnection()
    else:
        FileDescriptor.loseConnection(self)
