Hm... I haven't tried closing a window in that way from within a dialog. I wouldn't think that a dialog would store the location that it's created from. Most likely, it's closing the active message or most recent message window. Again, I've not tested it, but it just doesn't seem right that it would store that information and maintain it the entire time the dialog is open. You're in a sclick event and not even an init event, so....
Oh well, maybe I'll test it later. Regardless, I'd still recommend having a value there. And, personally, I would rather have it be automatic without a popup... if you're afk and get many people messaging you, you'll have one popup stuck on and then a bunch of errors saying the dialog already exists.