one way is use flags.
for example if window1 is open then put flag1=0 if it is closed flag1=1 and so on for other windows too.
the other way is using on error function.
i have shown below a sample program to check file is opened or not . you write a similar code for window.
open "abc.txt" for append as#1
on error goto [closed]
print "file cosed"