Add test for early 'end' event bug