If I host a WebBrowser in my application, and a javascript code in the web page shown on my WebBrowser calls window.close() and I click \"Yes\" on
WebBrowser
window.close()
There is an interface DWebBrowserEvents2 which has a method WindowClosing which you can use to cancel the window.close() call.
(I found the suggestion in this posting)