i have a console app that when it exits it saves everthing to file, i use atexit() but this does not always work only if the app is terminated by running out of code, it does not work if the user simply closes the command window, is ther some way to do the same as atexit but for it to work when the window is closed??