Hi Héctor,
such errors typically happen when you have dangling references and the user shuts down the application. In this case, some object are destroyed after the cursor is closed and after some regularly released objects are gone. Often the top level event in this case is the Destroy event, if you have code in there. To fix this you clean up code needs to make sure that all objects are properly released. Do not rely on VFP to do this for you. Alternatively, you could - after closing all tables - call the TerminateProcess API function which bypasses any of VFP's clean up attempts. While I don't call this function regularly, that's how I exit the application in case of an error to avoid subsequent error messages.
To avoid the error in the error handler put the USE statement in a TRY....CATCH block. While this doesn't fix the error it at least prevents the user from seeing a VFP error message.
--
Christof