def sendClose(self, channel):
        """
        Close a channel.

        @type channel:  subclass of L{SSHChannel}
        """
        if channel.localClosed:
            return # we're already closed
        log.msg('sending close %i' % channel.id)
        self.transport.sendPacket(MSG_CHANNEL_CLOSE, struct.pack('>L',
                self.channelsToRemoteChannel[channel]))
        channel.localClosed = True
        if channel.localClosed and channel.remoteClosed:
            self.channelClosed(channel)

        Close a channel.

        @type channel:  subclass of L{SSHChannel}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/ssh/connection.py