Randy/Thomas - depending on the scope of the application (wasn't quite
specified), this could be a system-audit requirement. Or, heaven
forbid, it might be a business requirement - the business types rarely
relent on many of these things.
In either case, Nagesh, your main problem is that the unload event
isn't cancelable. (
http://www.w3.org/TR/2000/REC-DOM-Level-2-
Events-20001113/events.html#Events-eventgroupings-htmlevents) In IE,
you can use the onbeforeunload event, but before you do that, I'd
really suggest taking a look at what you're actually trying to
accomplish here. I recently helped another developer at work to
implement a better solution to a similar problem - when the user
closes the main window in our product, we have to log them out of the
system, and the way this was handled at first was by opening a new
window on unload, and that new window loaded a page that ran the
logout scripts. Then IE7 and its default popup-blocking broke that,
and someone quickfixed it by sticking a "Are you sure you want to
navigate away from the page?" confirm dialog into onbeforeunload. It
annoyed the piss out of everyone, because it stopped the user from
closing the browser cleanly, and forced the user to kill the process
on shutdowns. We replaced it with a tiny AJAX call to the logout
script on unload (didn't even need a callback function), and it's much
less irritating for everyone. So, if you have any influence on the
design of this part, I'd really recommend looking at it a different
way - if they're going to close the browser window, there's not much
you can do to truly stop them, and you might as well just grab as much
information as possible right there so that you can run your processes
on your own without them there.
And I'll agree with the others here that this is a straight-up suicide
mission if you're designing for the big bad Internet. Nothing kills
traffic to a site like annoyances. (Unless your site is targeted at
clueless masses of teenagers and rock bands, in which case you're
MySpace and I hate you.

)