document 'end' event