clear events wait window "all events are cleared" timeout 1 =strtofile("Started on shutdown procedure"+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) if _screen.formcount > 0 m.testcount = 0 =strtofile("Forms collection "+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) for m.xx = 1 to _screen.formcount =strtofile("_screen.forms("+alltrim(str(m.xx))+") = "+_Screen.forms(m.xx).name+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) next =strtofile("End of Forms collection "+chr(13)+chr(10)+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) do while _screen.formcount > 0 m.form1 = _screen.forms(1).name =strtofile("attempting to release form "+"_screen.forms(1) = "+_Screen.forms(1).name+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) wait window "attempting to release form "+_Screen.forms(1).name timeout 1 *!* this code will release a modal form but the next form will not release *!* if _Screen.forms(1).windowtype = 1 && is a modal screen *!* m.thisactiveform = _screen.forms(1) *!* m.thisactiveform.visible = .f. *!* m.thisactiveform.show(2) *!* m.thisactiveform.release *!* m.thisactiveform = .null. *!* release m.thisactiveform *!* else *!* is not a modal screen *!* this code will release a a modeless form but not a modal form _Screen.forms(1).release *!* endif wait clear if _screen.formcount > 0 and m.form1 = _screen.forms(1).name *!* form did not release increment retry count to try up to to times to release *!* to prevent infinite loop if unable to release form m.testcount =m.testcount+1 else m.testcount = 0 endif if m.testcount > 10 *!* try exit wait window "could not release forms" endif enddo endif release all extended wait window "clearing all" timeout 1 *!* clear all returns error "cannot clear object in use" when modal screen is active clear all flush on shutdown wait window "finished on shutdown" timeout 1 =strtofile("Finished shutdown procedure"+chr(13)+chr(10) ,"shutdowntrace.txt",.t.) quitShutdowntrace.txt shows each form in the forms collection and each atttempt to release. When all active forms are modeless, there is no problem. But if Modal form, browse window or message box, release does not work and the app will not shutdown.