docs: def _closed_cb(self, final_frame=None):
          '''
          "Private" callback from the ChannelClass when a channel is closed. Only
          called after broker initiated close, or we receive a close_ok. Caller
          has the option to send a final frame, to be used to bypass any
          synchronous or otherwise-pending frames so that the channel can be
          cleanly closed.
          '''
          # delete all pending data and send final frame if thre is one. note
          # that it bypasses send_frame so that even if the closed state is set,
          # the frame is published.
          if final_frame:
              self._connection.send_frame(final_frame)
  
          try:
              self._notify_close_listeners()
          finally:
              self._pending_events = deque()
              self._frame_buffer = deque()
  
              # clear out other references for faster cleanup
              for protocol_class in self._class_map.values():
                  protocol_class._cleanup()
                  delattr(self, protocol_class.name)
              self._connection = None
              self._class_map = None
              self._close_listeners = set()