There's a typo in my comment, it should be "unload
events are not cancelable...".
You can force window B to be closed just before closing A using WMI, something like this:
top.onbeforeunload = function () {
var wmiLocator = new ActiveXObject('WbemScripting.SWbemLocator'),
wmiService = wmiLocator.ConnectServer('.', 'root\\CIMV2'),
htaProcesses = new Enumerator(wmiService.ExecQuery("Select * from Win32_Process Where name = 'mshta.exe'")),
htas = [], n;
while (!htaProcesses.atEnd()) {
if (htaProcesses.item().CommandLine.indexOf('Launcher-Settings.hta') > -1) {
htas.push(htaProcesses.item());
}
htaProcesses.moveNext();
}
for (n = 0; n < htas.length; n++) {
htas[n].Terminate();
}
return;
}