code: func (c *ServerContext) takeClosers() []io.Closer {
  	// this is done to avoid any operation holding the lock for too long
  	c.Lock()
  	defer c.Unlock()
  
  	closers := []io.Closer{}
  	if c.term != nil {
  		closers = append(closers, c.term)
  		c.term = nil
  	}
  	if c.agentChannel != nil {
  		closers = append(closers, c.agentChannel)
  		c.agentChannel = nil
  	}
  	closers = append(closers, c.closers...)
  	c.closers = nil
  	return closers
  }
docs: // takeClosers returns all resources that should be closed and sets the properties to null
  // we do this to avoid calling Close() under lock to avoid potential deadlocks