Why don't you want people being able to have multiple copies open? Usually that's an advantage -- at least for the user -- since then you can put them side-by-side and look at different parts at the same time?
Generally a tab/window being closed is none of a web app's business, I'm surprised you got it to work at all -- but...
How about you set up a push or polling system where every time a new copy is opened, you give it a unique random hash. When a copy is opened you push "X hash opened for Y user" and have each open copy of the app respond "I'm here". If more than one responds, warn in the new ones but not the oldest one. It's a bit more back-and-forth but would be more reliable than trying to trap the tab closure.
Especially since it could go cross-browser / cross-machine. That way if you have a reason to never allow more than one copy open they can't open it on the desktop and their mobile device at the same time.