Hello PRK123,
first of all, you are reviving an old thread with an unrelated question. In this case it is always better to start a new discussion instead.
Having said this, I can give you a conceptual framework for you to elaborate on. To accomplish your task you need a periodic function that checks execution time: this can be obtained with a timer firing a slow rate (say once per minute). in the timer callback you have to elaborate the time figure and decide if you need to shutdown the application: in this case you prompt a message and issue a call to QuitUserInterface. Before closing the application you may need to stop ongoing processes (e.g. acquisition tasks) and dispose of allocated resources (connected external devices, open files and so on).