code: func (c *Client) end(err error, possiblyClosed bool) error {
  	// close connection
  	err = c.cleanup(err, true, true)
  
  	// shutdown goroutines
  	c.tomb.Kill(nil)
  
  	// wait for all goroutines to exit
  	// goroutines will send eventual errors through the callback
  	c.tomb.Wait()
  
  	// do cleanup
  	return err
  }
docs: // called by Disconnect and Close