code: func (c *Client) cleanup() {
  	// check if not cleanly connected and will is present
  	if atomic.LoadUint32(&c.state) == clientConnected && c.will != nil {
  		// publish message
  		err := c.backend.Publish(c, c.will, nil)
  		if err != nil {
  			c.backend.Log(BackendError, c, nil, nil, err)
  		}
  
  		c.backend.Log(MessagePublished, c, nil, c.will, nil)
  	}
  
  	// remove client from the queue
  	if atomic.LoadUint32(&c.state) >= clientConnected {
  		err := c.backend.Terminate(c)
  		if err != nil {
  			c.backend.Log(BackendError, c, nil, nil, err)
  		}
  	}
  
  	c.backend.Log(LostConnection, c, nil, nil, nil)
  }
docs: // will try to cleanup as many resources as possible