LOCAL lnForm, lnFormToClose lnFormToClose = 1 FOR lnForm = 1 TO _screen.FormCount IF TYPE("_screen.Forms(lnFormToClose)") == "O" IF _screen.Forms(lnFormToClose).QueryUnload() _screen.Forms(lnFormToClose).Release() ELSE RETURN .F. ENDIF ELSE lnFormToClose = lnFormToClose + 1 ENDIF ENDFOR CLEAR EVENTS DO cleanup...and Cleanup does CLOSE DATABASES, CLEAR ALL, SET CLASSLIB TO, and so forth.