Hi...and a JS/ExternalInterface question

Hey, it’s my first post on Kirupa…
I asked this over at flashkit but nobody seemed on to help me. This is AS3-related but really more of a client/browser/JS issue…
I’ve got a piece of flash code sitting in a page that’s got a socket open to a server. I want it to send one last “goodbye” to the server if the user closes the window or goes to another URL.
Using an onbeforeunload in the body tag, I got this working as long as the user is navigating to a new page in the same tab. But if the user closes the tab or quits the browser, there isn’t enough time for the ExternalInterface callback to reach Flash, or for Flash to hit the server (not sure which one of those two steps fails, actually, but I’m guessing the callback itself).
Now – I’ve noticed that gmail hangs my browser for about 5 seconds every time I close a window where I had it open. It’s accompanied by a burst of outbound network traffic. Spinning wheel and the whole thing. I think they must be running some kinda sneaky JS loop that hangs the browser when you try to close out of it. This becomes very apparent on a slow connection, and it even happens when you quit the browser completely.
I’m wondering if anyone knows how they’re pulling this off, and also whether such a delay would just prevent the VM from doing what it needs to do simultaneously, if I tried to run some action through Flash this way.
Sorry for the sort of off-topic question, maybe this belongs in scripting/backend or, maybe not. I’d appreciate any advice…
Cheers,
Josh