// stop in reverse topological order
420606
func (s *Service) stop() {
	dc := make(chan struct{})
	go func() {
		for i := len(s.modules) - 1; i >= 0; i-- {
			n := getModuleName(s.modules[i])
			c := s.configs[n]
			if c.Stop != nil {
				BootPrintln("[service] stopping", n)
				c.Stop()
			}
		}
		dc <- struct{}{}
	}()

	select {
	case <-dc:
	case <-time.After(30 * time.Second): // todo: make this configurable
		BootPrintln("[service] stop timed out")
	}
}
1061894
func (c *CCProviderImpl) Stop(ccci *ccprovider.ChaincodeContainerInfo) error {
	return c.cs.Stop(ccci)
}
115310
func (t *Transport) Stop() error {
	return t.once.Stop(func() error {
		t.lock.Lock()
		defer t.lock.Unlock()
		for _, grpcPeer := range t.addressToPeer {
			grpcPeer.stop()
		}
		var err error
		for _, grpcPeer := range t.addressToPeer {
			err = multierr.Append(err, grpcPeer.wait())
		}
		return err
	})
}
33844
func (n *NomadAgent) Stop() error {
	if err := n.Cmd.Process.Signal(os.Interrupt); err != nil {
		return err
	}

	return n.Cmd.Wait()
}
1104257
func (s *Instancer) Stop() {
	q := make(chan struct{})
	s.quitc <- q
	<-q
	s.quitc = nil
}
576284
func (sit *SyncIntervalTimer) Stop() {
	sit.stop <- struct{}{}
	if sit.intervalTimer != nil {
		sit.intervalTimer.Stop()
	}
}
797358
func (b *Driver) Stop() error {
	b.pcmdMutex.Lock()
	defer b.pcmdMutex.Unlock()

	b.Pcmd = Pcmd{
		Flag:  0,
		Roll:  0,
		Pitch: 0,
		Yaw:   0,
		Gaz:   0,
		Psi:   0,
	}

	return nil
}
1366101
func Stop() {
	// Wait for on-going traces.
	globals.wg.Wait()
	globals.lockWriter.Lock()
	defer globals.lockWriter.Unlock()
	globals.lockContexts.Lock()
	defer globals.lockContexts.Unlock()
	if globals.out != nil {
		// TODO(maruel): Dump all the stack frames.
		_, _ = globals.out.Write(footerEvents)
	}
	globals.lockID.Lock()
	defer globals.lockID.Unlock()
	globals.out = nil
	globals.contexts = nil
	globals.nextPID = 0
	globals.nextID = 0

	// Lower back clock frequency once we're done.
	lowerClockFrequency()
}
862024
func (c *CouchDB) Stop() error {
	c.mutex.Lock()
	if c.stopped {
		c.mutex.Unlock()
		return errors.Errorf("container %s already stopped", c.containerID)
	}
	c.stopped = true
	c.mutex.Unlock()

	err := c.Client.StopContainer(c.containerID, 0)
	if err != nil {
		return err
	}

	return nil
}
982226
func (srv *Server) Stop() error {
	srv.tomb.Kill(nil)
	return srv.tomb.Wait()
}
391674
func (driver *MesosSchedulerDriver) Stop(failover bool) (mesos.Status, error) {
	driver.eventLock.Lock()
	defer driver.eventLock.Unlock()
	return driver.stop(driver.context(), nil, failover)
}
296120
func (a *Transport) Stop() error {
	return a.once.Stop(func() error {
		a.connectorsGroup.Wait()
		return nil
	})
}
183465
func (c *testCluster) Stop() error {
	c.cancel()
	for _, n := range c.nodes {
		if err := n.Stop(); err != nil {
			return err
		}
	}
	c.wg.Wait()
	close(c.errs)
	for err := range c.errs {
		if err != nil {
			return err
		}
	}
	return nil
}
1346032
func (le *leaderElectionSvcImpl) Stop() {
	le.logger.Debug(le.id, ": Entering")
	defer le.logger.Debug(le.id, ": Exiting")
	atomic.StoreInt32(&le.toDie, int32(1))
	le.stopChan <- struct{}{}
	le.stopWG.Wait()
}
119261
func (c *SSHTunneler) Stop() {
	if c.stopChan != nil {
		close(c.stopChan)
		c.stopChan = nil
	}
}
955056
func Stop(w Stopper, t *tomb.Tomb) {
	if err := w.Stop(); err != nil {
		if err != tomb.ErrStillAlive && err != tomb.ErrDying {
			// tomb.Kill() checks for the two errors above
			// by value, so we shouldn't wrap them, but we
			// wrap any other error.
			err = errors.Trace(err)
		}
		t.Kill(err)
	}
}
622427
func (g *gossipServiceImpl) Stop() {
	if g.toDie() {
		return
	}
	atomic.StoreInt32(&g.stopFlag, int32(1))
	g.logger.Info("Stopping gossip")
	g.chanState.stop()
	g.discAdapter.close()
	g.disc.Stop()
	g.certStore.stop()
	g.toDieChan <- struct{}{}
	g.emitter.Stop()
	g.ChannelDeMultiplexer.Close()
	g.stateInfoMsgStore.Stop()
	g.stopSignal.Wait()
	g.comm.Stop()
}