Moved the emitter to emit before the end event emitter