code: func (s *ChainService) Stop() error {
  	// Make sure this only happens once.
  	if atomic.AddInt32(&s.shutdown, 1) != 1 {
  		return nil
  	}
  
  	s.connManager.Stop()
  	s.broadcaster.Stop()
  	s.utxoScanner.Stop()
  	s.blockSubscriptionMgr.Stop()
  	s.blockManager.Stop()
  	s.addrManager.Stop()
  
  	// Signal the remaining goroutines to quit.
  	close(s.quit)
  	s.wg.Wait()
  	return nil
  }
docs: // Stop gracefully shuts down the server by stopping and disconnecting all
  // peers and the main listener.