If you wanted to do something like that it would be easy to script.
Just have an array that stores references to all open windows. Have a button that, when clicked, runs a for loop, or while loop, however you want to do it, and cycles through the windows that closes the windows in turn. You can make them invisible, close them, whatever you want to do.
As far as your menu thing goes, is the menu a window? Is the button active all the time? It should be easy enough to have the button close a window. You should be able to figure it out by looking at the close buttons on the default windows and emulating that. If you can post perhaps some code or even screenshots, if you're willing, of how it is all set up it would be easier to guide you a bit.