Ah, I've figured out the problem.
I am running a few instances of IE, and the IE I was testing
is the last one. I use www.cheatcc.com/frames.html to test it.
Apparently your code doesn't add(or detect?) the last instance,
so the popup pops. So, in conclusion, ur code actually works!

Actually, u're genius, ur code runs great, just buggy hehe