code: func (i *AgentIPC) deregisterClient(client *IPCClient) {
  	// Close the socket
  	client.conn.Close()
  
  	// Remove from the clients list
  	i.Lock()
  	delete(i.clients, client.name)
  	i.Unlock()
  
  	// Remove from the log writer
  	if client.logStreamer != nil {
  		i.logWriter.DeregisterHandler(client.logStreamer)
  		client.logStreamer.Stop()
  	}
  
  	// Remove from event handlers
  	for _, es := range client.eventStreams {
  		i.agent.DeregisterEventHandler(es)
  		es.Stop()
  	}
  }
docs: // deregisterClient is called to cleanup after a client disconnects