The problem with your script is, that the window must have been created, before you can destroy it. You should be able to overcome this problem by replacing the faulty line with this:
JScript code:
if(typeof Wnd === "object" && Wnd !== null) Wnd.Close();
I'm pretty sure this'll do it...