code: func (s *Server) Shutdown() error {
  	s.logger.Printf("[INFO] consul: shutting down server")
  	s.shutdownLock.Lock()
  	defer s.shutdownLock.Unlock()
  
  	if s.shutdown {
  		return nil
  	}
  
  	s.shutdown = true
  	close(s.shutdownCh)
  
  	if s.serfLAN != nil {
  		s.serfLAN.Shutdown()
  	}
  
  	if s.serfWAN != nil {
  		s.serfWAN.Shutdown()
  		if err := s.router.RemoveArea(types.AreaWAN); err != nil {
  			s.logger.Printf("[WARN] consul: error removing WAN area: %v", err)
  		}
  	}
  	s.router.Shutdown()
  
  	if s.raft != nil {
  		s.raftTransport.Close()
  		s.raftLayer.Close()
  		future := s.raft.Shutdown()
  		if err := future.Error(); err != nil {
  			s.logger.Printf("[WARN] consul: error shutting down raft: %s", err)
  		}
  		if s.raftStore != nil {
  			s.raftStore.Close()
  		}
  	}
  
  	if s.Listener != nil {
  		s.Listener.Close()
  	}
  
  	// Close the connection pool
  	s.connPool.Shutdown()
  
  	return nil
  }
docs: // Shutdown is used to shutdown the server