'Close the underlying handle or, if TLS has been started, first shut it
down.
@see: L{twisted.internet.interfaces.ITransport.loseConnection}'

def loseConnection(self, reason=None):

    if self.TLS:
        if (self.connected and (not self.disconnecting)):
            self.protocol.loseConnection()
    else:
        abstract.FileHandle.loseConnection(self, reason)
