Obviously your program can't do anything after it closed, because it is not running any more ..
The idea would be to find when the program closes, and save what you need before that happens.
The only way to interact with the hard drive you should be concerned about is using files. You are not restricted to text files. To see how, see http://www.cplusplus.com/doc/tutorial/files/