So I have the following, working, code for getting clean exit performed when user interrupts the program (ie. ctrl-c in terminal), so that global destructors, etc. will be run.