Move 'end' event to correct location