You can only detect a window if:
1) you know the name of the window, or
2) you have a pointer to the window because you opened it, or
3) you are in a child window and you want to know about your opener.
Even if you know the name, you still need a pointer. You can get a pointer to a window called "theName" using:
var myWin = window.open("", "theName");
Unfortunately, if the window does not exist, this will open a new empty window.
Once you have a pointer, you can test if the window is closed: