Closing Forms problem

Hello :). Have you ever had problems with closing forms? I have application with one form which is being created at runtime. The problem is that if the user closes the form the application process still stays.

private function loadNewOne():void {
            mdm.Forms.getFormByName("MainForm").show();
            mdm.Forms.getFormByName("SubForm1").hide();
        }
        
        private function ExitApplication():void {
            mdm.Forms.getFormByName("MainForm").show();
            mdm.Forms.getFormByName("SubForm1").hide();
        }
]

I am unable to listen or event something to the mainform, do you have any idea how can i close the mainform simultaneously with the subform?