optimized window.onunload client quit