code: func (s *Server) Shutdown(ctx context.Context) error {
  	// wait until connections drain off
  	err := s.srv.Shutdown(ctx)
  	s.cancel()
  	s.reg.Close()
  	if s.heartbeat != nil {
  		if err := s.heartbeat.Close(); err != nil {
  			s.Warningf("Failed to close heartbeat: %v.", err)
  		}
  		s.heartbeat = nil
  	}
  	return err
  }
docs: // Shutdown performs graceful shutdown