>The best way is to make new class based on timer. Than add it in run-time to any object that is global and exists all the time application runs. In your case this may be main top-level form. If modal form opened - this is not a problem, timer event will fire anyway.
>
>Than, in your class in timer event check datetime() and shutdown application. Be sure no errors during forcing of form close, and no 'table open' dialog boxes appear because thay will prevent automatic shutdown requiring user interaction. When some form have data unsaved, that form should not show dialog boxes, so you will need a way to indicate that you're in shutdown mode. I usually use global logical variable flag for that. When it is .T., I avoid any dialog boxes and revert any changes in tables.
>
>Only cases when timer event will not fire - Windows Open dialog boxes (like file selection by GetFile(), color selection by GetColor, diirecory selection by GetDir() etc.) It aso will not work whan application hangs up.
>
It also won't fire if the VFP menu or a popup is active, or if VFP is running a tight loop with no UI interaction within a single procedure or method. It also will not interrupt a single long running SQL statement. The timer will fire (repeatedly) in these circumstances, and timer messages will queue up until VFP changes procedures or runs a UI statement that allows it to check the message queues.
Bela Bodecs has a file in the Files section that is less vulnerable to having the event not detected where you anticipate these types of programming conditions.