It's bad design to have to code that way. Ideally, you should write your application in a way that can deal with this situation - if the user opens a new window after closing the current one and is still logged in, is that really a big deal?

Think of Facebook, VBForums, Flickr, etc... the applications work fine even if you return in a new window.

Having said that, I did once write something for it...

http://www.vbforums.com/showthread.php?t=391028