All my forms are created from within functions (with properly dimmed variables) and they have their own event loop at the bottom that exits when the form or any of its parents are closed. When the loop (and therefore the function exits) all variables relating to the form are cleaned up by the KiXtart interpreter.

On a side note, when you have multiple forms open, the events of all the forms are being processed in the query loop of the last opened form.