handle error and shutdown for event emitter