code: func (c *rawConnection) internalClose(err error) {
  	c.closeOnce.Do(func() {
  		l.Debugln("close due to", err)
  		close(c.closed)
  
  		c.awaitingMut.Lock()
  		for i, ch := range c.awaiting {
  			if ch != nil {
  				close(ch)
  				delete(c.awaiting, i)
  			}
  		}
  		c.awaitingMut.Unlock()
  
  		// Wait for all our operations to terminate before signaling
  		// to the receiver that the connection was closed.
  		c.wg.Wait()
  
  		// No more sends are necessary, therefore further steps to close the
  		// connection outside of this package can proceed immediately.
  		// And this prevents a potential deadlock.
  		go c.receiver.Closed(c, err)
  	})
  }
docs: // internalClose is called if there is an unexpected error during normal operation.