In lua, when a form is opened like this
var = forms.newform(240,260,"Edit Action Commands")
then var becomes a number. You can suspend opening multiples of the same form by checking if var is not nil. And you can set var to nil at the same time you would destroy the form when clicking on a close button, so that you can create the form window again (since var is nil again).
The problem is, that you can't seem to run your own custom function when clicking on the X in the top right, in order to close the form window. Doing so will not set var to nil. So you cannot create the form window anymore if you suspend creating them if var is nil.
Phew, I hope what I wrote is understandable.
Basicly, I want to create only 1 of a same form window at a time, that's why there's all this trouble about checking if var is nil or not.
Maybe another way to look at this is, that the actual problem is that forms.destroy does not set var to nil. Maybe it should.
Also, it doesn't seem like running:
var = nil
inside the onexit codeblock works.
Tools > Toolbox
opening the toolbox when the Bizhawk client is on the right side of the screen makes it so that the toolbox window is offscreen and invisible to the user.
Opening a lua script that uses an image, then closing the script (the lua console is closed) will make it so that the image is still in use by Bizhawk, when it is really not.