How can i trap the closing time of an application.