Yep,
I think I feel your pain.
When you dismiss a window it's gone. The window id has changed too
(and the title is now its name).
I think as far as AppleScripts is concerned, the old one doesn't
exist anymore.
How I solved this problem is by using the "should close" handler to
make sure the window is made
invisible, instead of being lost forever.
on should close This
set {doClose, This} to {true, name of This}
if (This = "foo") then set {doClose, visible of window This}
to {false, false}
return doClose
end should close