The 'end' event should be emitted when ending