code: func (a *Agent) Stop(ctx context.Context) error {
  	select {
  	case <-a.started:
  	default:
  		return errAgentNotStarted
  	}
  
  	a.stop()
  
  	// wait till closed or context cancelled
  	select {
  	case <-a.closed:
  		return nil
  	case <-ctx.Done():
  		return ctx.Err()
  	}
  }
docs: // Stop shuts down the agent, blocking until full shutdown. If the agent is not
  // started, Stop will block until the agent has fully shutdown.