code: func (ed *Dispatcher) HandleStopEvent(e Event) {
  	event := e.(*StopEvent)
  
  	logger.Debugf("Stopping dispatcher...")
  	if !ed.setState(dispatcherStateStarted, dispatcherStateStopped) {
  		logger.Warn("Cannot stop event dispatcher since it's already stopped.")
  		event.ErrCh <- errors.New("dispatcher already stopped")
  		return
  	}
  
  	// Remove all registrations and close the associated event channels
  	// so that the client is notified that the registration has been removed
  	ed.clearRegistrations(true)
  
  	event.ErrCh <- nil
  }
docs: // HandleStopEvent stops the dispatcher and unregisters all event registration.
  // The Dispatcher is no longer usable.