Try to catch onbeforeunload event in web page to exit process when window is closed.