The application I am working on uses a main page with a kind of menu. This page opens other windows but it always stays the same. I added some functionality to keep track of all the windows opened and close them onunload of the main page. It works fine unless one of the opened pages has a modal window open.

Is there any way to close the modal before closing the window? Right now it just beeps and leaves the modal and window behind it open. It doesn't affect the execution of the script otherwise.

Thanks,
Brian