code: func (process *TeleportProcess) onExit(serviceName string, callback func(interface{})) {
  	process.RegisterFunc(serviceName, func() error {
  		eventC := make(chan Event)
  		process.WaitForEvent(context.TODO(), TeleportExitEvent, eventC)
  		select {
  		case event := <-eventC:
  			callback(event.Payload)
  		}
  		return nil
  	})
  }
docs: // onExit allows individual services to register a callback function which will be
  // called when Teleport Process is asked to exit. Usually services terminate themselves
  // when the callback is called