'Called when a channel is closed.
It clears the local state related to the channel, and calls
channel.closed().
MAKE SURE YOU CALL THIS METHOD, even if you subclass L{SSHConnection}.
If you don\'t, things will break mysteriously.
@type channel: L{SSHChannel}'

def channelClosed(self, channel):

    if (channel in self.channelsToRemoteChannel):
        channel.localClosed = channel.remoteClosed = True
        del self.localToRemoteChannel[channel.id]
        del self.channels[channel.id]
        del self.channelsToRemoteChannel[channel]
        for d in self.deferreds.setdefault(channel.id, []):
            d.errback(error.ConchError('Channel    closed.'))
        del self.deferreds[channel.id][:]
        log.callWithLogger(channel, channel.closed)
