Delete all windows of a specific type

Is there a way to close all windows of a specific type (or name) currently on screen with a short code snippet?

Best regards!
Code:
for (var i in SceneManager._scene._windowLayer.children) {
if (SceneManager._scene._windowLayer.children[i].constructor == Window_Help) {
SceneManager._scene._windowLayer.children[i].hide()
}
}
Hides these windows.

Edit: Had a couple of unexpected problems to solve due to formatting, be sure to check the current version.
Not really?
basically these windows don't really have a name, they have a type and it depends where you are trying to do this.
be aware that some windows rely on each other and may or may not causes glitches if you close them unexpectedly.

Code:
//this first line may cause errors if a scene doesn't have a window layer!!
// use with caution!
var windows = SceneManager._scene._windowLayer.children;
var winTypes = ["Window_Equip", "Window_Gold"];
if (windows) {
    windows.forEach(function (element) {
        if (windTypes.contains(typeof element)) {
            element.close();
        }
    });
}
Code:
for (var i in SceneManager._scene._windowLayer.children) {
if (SceneManager._scene._windowLayer.children[i].constructor == Window_Help) {
SceneManager._scene._windowLayer.children[i].hide()
}
}
Hides these windows.

Edit: Had a couple of unexpected problems to solve due to formatting, be sure to check the current version.

Exactly what I needed, works 100% perfect. Thank you!

(I needed this for an additional battle order window to close before the battle result screen kicks in, doesn't seem to cause any dependency troubles.)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/delete-all-windows-of-a-specific-type.103876/