Add window close event hook.