I have an application in VB6 for which I am implementing the Autologout functionality. Whenever the application is in idle state for some time, the user will be logedout by closing all the forms that user has been loaded. I am using a FormStack and unloading all the forms that has been loaded. Inorder to close the forms in a proper way we are using SendKeys ESC and the form will unload with ESC key. It is working fine in most of the cases, but the problem is if there is something like Keyboard, then with the ESC key the keyboard is getting unloaded, but once all the forms are unloaded, the code next to Keyboard is getting executed which has a reference to forms control and loading the form. I can do the reference checks, but this functionality is implemented in many places, and it takes time to check everywhere. I also thought to wait for some time around 500 ms to close every form, but felt it is not good to relay on timers. Could anyone suggest a better idea to uload all the forms smoothly. Thanks in advance.