// Close stops the server and the kontrol client instance.
322242
func (k *Kite) Close() {
	k.Log.Info("Closing kite...")

	k.kontrol.Lock()
	if k.kontrol != nil && k.kontrol.Client != nil {
		k.kontrol.Close()
	}
	k.kontrol.Unlock()

	if k.listener != nil {
		k.listener.Close()
		k.listener = nil
	}

	k.mu.Lock()
	cache := k.verifyCache
	k.mu.Unlock()

	if cache != nil {
		cache.StopGC()
	}
}
1338525
func (s *Server) Close() {
	s.mu.Lock()
	if !s.closed {
		s.closed = true
		s.Listener.Close()
		s.Config.SetKeepAlivesEnabled(false)
		for c, st := range s.conns {
			// Force-close any idle connections (those between
			// requests) and new connections (those which connected
			// but never sent a request). StateNew connections are
			// super rare and have only been seen (in
			// previously-flaky tests) in the case of
			// socket-late-binding races from the http Client
			// dialing this server and then getting an idle
			// connection before the dial completed. There is thus
			// a connected connection in StateNew with no
			// associated Request. We only close StateIdle and
			// StateNew because they're not doing anything. It's
			// possible StateNew is about to do something in a few
			// milliseconds, but a previous CL to check again in a
			// few milliseconds wasn't liked (early versions of
			// https://golang.org/cl/15151) so now we just
			// forcefully close StateNew. The docs for Server.Close say
			// we wait for "outstanding requests", so we don't close things
			// in StateActive.
			if st == http.StateIdle || st == http.StateNew {
				s.closeConn(c)
			}
		}
		// If this server doesn't shut down in 5 seconds, tell the user why.
		t := time.AfterFunc(5*time.Second, s.logCloseHangDebugInfo)
		defer t.Stop()
	}
	s.mu.Unlock()

	// Not part of httptest.Server's correctness, but assume most
	// users of httptest.Server will be using the standard
	// transport, so help them out and close any idle connections for them.
	if t, ok := http.DefaultTransport.(closeIdleTransport); ok {
		t.CloseIdleConnections()
	}

	// Also close the client idle connections.
	if s.client != nil {
		if t, ok := s.client.Transport.(closeIdleTransport); ok {
			t.CloseIdleConnections()
		}
	}

	s.wg.Wait()
}
552541
func (c *Client) Close() error {
	c.once.Do(func() { close(c.done) })
	c.Flush()
	return nil
}
185511
func (s *listenerStreamServer) Close() {
	if s.l == nil {
		panic("server is not currently serving")
	}

	// Mark that we've been closed.
	atomic.StoreInt32(&s.closed, 1)

	// Close our Listener. This will cause our 'Accept' goroutine to terminate.
	s.l.Close()
	close(s.closedC)
	<-s.acceptFinishedC

	// Close our streamParamsC to signal that we're closed. Any blocking Next will
	// drain the channel, then return with nil.
	close(s.streamParamsC)
	s.l = nil
}
762523
func (h *Handler) Close() error {
	h.client.Close()
	h.client.Wait()

	return nil
}
706777
func (c *Client) Close() error {
	c.connMu.Lock()
	defer c.connMu.Unlock()
	if c.conn != nil {
		return c.conn.Close()
	}
	return nil
}
877829
func (c *Client) Close() error {
	for _, s := range c.subs {
		s.Unsubscribe()
	}
	return nil
}
1198641
func (c *client) Close() {
	c.closeOnce.Do(func() {
		close(c.done)
		if c.clientType == adminClient {
			if ac := c.adminRegionInfo.Client(); ac != nil {
				ac.Close()
			}
		}
		c.clients.closeAll()
	})
}
935442
func (c *GRPCClient) Close() error {
	c.broker.Close()
	c.controller.Shutdown(c.doneCtx, &plugin.Empty{})
	return c.Conn.Close()
}
1176572
func (sw *SocketWriter) Close() error {
	if sw.Conn == nil {
		return nil
	}
	err := sw.Conn.Close()
	sw.Conn = nil
	return err
}
662847
func (c *Client) Close() error {
	if !c.running.Swap(false) {
		return nil // already stopped
	}

	var errors []error
	if err := c.stdout.Close(); err != nil {
		errors = append(errors, fmt.Errorf("failed to detach stdout from %q: %v", c.cmd.Path, err))
	}
	if err := c.stdin.Close(); err != nil {
		errors = append(errors, fmt.Errorf("failed to detach stdin from %q: %v", c.cmd.Path, err))
	}
	if err := c.cmd.Wait(); err != nil {
		errors = append(errors, fmt.Errorf("%q failed with: %v", c.cmd.Path, err))
	}
	return multierr.Combine(errors...)
}
38769
func (c *Client) Close() error {
	close(c.quit)
	c.wg.Wait()
	return c.db.Close()
}
1330102
func (c *Client) Close() error {
	c.once.Do(c.startLoop)
	c.quit <- struct{}{}
	close(c.msgs)
	<-c.shutdown
	return nil
}
262263
func (s *Client) Close() error {
	if s == nil {
		return nil
	}

	err := s.sender.Close()
	return err
}
387545
func (cf *ClientFactory) Close() {
	cf.mux.Lock()
	defer cf.mux.Unlock()
	if cf.client != nil {
		cf.client.close()
	}
}
1246416
func (c *Connection) Close() error {
	c.lock.Lock()
	defer c.lock.Unlock()

	if c.client != nil {
		err := c.client.Close()
		for waiterID := range c.closeWaiters {
			close(c.closeWaiters[waiterID])
		}
		c.client = nil
		return err
	}
	return nil
}
238869
func (s *Server) Close(timeout time.Duration) {
	if timeout <= 0 {
		for _, server := range s.servers {
			if err := server.Close(); err != nil {
				s.Logger.Warnf("web > Server [%s] shutdown failed: %s", server.Addr, err)
			} else {
				s.Logger.Infof("web > Server [%s] shutdown successfully", server.Addr)
			}
		}
	} else {
		ctx, cancel := scontext.WithTimeout(scontext.Background(), timeout)
		defer cancel()

		var g sync.WaitGroup
		g.Add(len(s.servers))
		for _, server := range s.servers {
			go func(server *http.Server) {
				if err := server.Shutdown(ctx); err != nil {
					s.Logger.Warnf("web > Server [%s] shutdown failed: %s", server.Addr, err)
				} else {
					s.Logger.Infof("web > Server [%s] shutdown gracefully", server.Addr)
				}
				g.Done()
			}(server)
		}
		g.Wait()
	}
}