I see 2 solutions to your problem.
(a)
You have to activate the window before being able to do anything else with it, including closing, resizing, iconifying it. Most people wouldn't like that I guess. I wouldn't mind - and in fact usually do exactly this. (eg first activate it, then close...