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
Which version of the WebBrowser control are you using? The WinForms one or the WPF one?
For the WinForms control, you can try to handle the Disposed or the HandleDestroyed event of the WebBrowser control in order to close your parent form too. For the WPF control, you can try the same with the Unloaded event.
I don't know if other JS code can lead to the same problems.