rearranged methods in close to allow close event handlers before trash