You have to have a way to know which forms you want to unload. I'm not aware of a way in VB6 to detect if a form is shown modally but you could always use the tag property or something like that.

...