code: func (c *ChainIndexer) Close() error {
  	var errs []error
  
  	c.ctxCancel()
  
  	// Tear down the primary update loop
  	errc := make(chan error)
  	c.quit <- errc
  	if err := <-errc; err != nil {
  		errs = append(errs, err)
  	}
  	// If needed, tear down the secondary event loop
  	if atomic.LoadUint32(&c.active) != 0 {
  		c.quit <- errc
  		if err := <-errc; err != nil {
  			errs = append(errs, err)
  		}
  	}
  	// Close all children
  	for _, child := range c.children {
  		if err := child.Close(); err != nil {
  			errs = append(errs, err)
  		}
  	}
  	// Return any failures
  	switch {
  	case len(errs) == 0:
  		return nil
  
  	case len(errs) == 1:
  		return errs[0]
  
  	default:
  		return fmt.Errorf("%v", errs)
  	}
  }
docs: // Close tears down all goroutines belonging to the indexer and returns any error
  // that might have occurred internally.