Thanks to Borissov and Hugo for responding. I still don't know what the problem was but I "resolved" it by re-creating the form from the VFP Form class rather than our standard form sub-class.
My guess (all other thoughts welcome) is that there was a dangling reference that prevents VFP from closing. If that is the cause, any thoughts on how to trace it down will be welcome.
Thanks again.............Rich
>I'm missing something basic and can't quite come up with it.
>
>I created a project with the following program set as main
> ... some preliminary SETS
>
>oData = NEWOBJECT("app_data_env","progs\data_env.prg")
>SET DATASESSION TO oData.datasessionid
>oDataClass = NEWOBJECT("dataclass","libs\spotlightclasses")
>
>_vfp.Caption = "Build Hardware Tray"
>_SCREEN.WindowState = 2
>
>DO FORMS forms\frmtouchbuildtray WITH oData,oDataClass
>READ EVENTS
>
>MESSAGEBOX("Main Form Done")
>
>QUIT
>
>The form starts up correctly and executes correctly.
>There is a command button (cmdExit) with the following
>CLEAR EVENTS
>thisform.Release
>
>The QueryUnload event has
>thisform.cmdExit.Click()
>
>When I click on cmdExit the form disappears but the main VFP window stays active. I don't get the "Main Form Done" messagebox and trying to close the main VFP window gets the "Cannot Quit VFP" message.
>
>What have I missed????
>
>Thanks to all............Rich