How can I prevent a page unload with jQuery?
way down in the comments it says:
event.preventDefault() doesn't work in this case, presumably because modern browsers don't want malicious coders to hijack the window and make it un-closable? – yochannah May 9 '13 at 8:45
I dont believe it is possible to delay it longer then it takes for that code to execute, excluding any async returns and timeouts.
So, to hack this. Call your disconnect, then make a synchronous call to a file which does
<?php
sleep(1);