code: func (b *bufferedBackend) Shutdown() {
  	// Wait until the routine spawned in Run method exits.
  	<-b.shutdownCh
  
  	// Wait until all sending routines exit.
  	//
  	// - When b.shutdownCh is closed, we know that the goroutine in Run has terminated.
  	// - This means that processIncomingEvents has terminated.
  	// - Which means that b.buffer is closed and cannot accept any new events anymore.
  	// - Because processEvents is called synchronously from the Run goroutine, the waitgroup has its final value.
  	// Hence wg.Wait will not miss any more outgoing batches.
  	b.wg.Wait()
  
  	b.delegateBackend.Shutdown()
  }
docs: // Shutdown blocks until stopCh passed to the Run method is closed and all
  // events added prior to that moment are batched and sent to the delegate backend.