code: def client_end(request, socket, context):
      
      # Send the unsubscribe event prior to actually unsubscribing, so
      # that the finish event can still match channels if applicable.
      for channel in socket.channels:
          events.on_unsubscribe.send(request, socket, context, channel)
      events.on_finish.send(request, socket, context)
      # Actually unsubscribe to cleanup channel data.
      for channel in socket.channels[:]:
          socket.unsubscribe(channel)
      # Remove the client.
      del CLIENTS[socket.session.session_id]
docs: Handles cleanup when a session ends for the given client triple.
      Sends unsubscribe and finish events, actually unsubscribes from
      any channels subscribed to, and removes the client triple from
      CLIENTS.