add close event handler.
add test case for close event.