log: add destructor mechanism

Calls to LogFatal and app-closing interrupt signals will execute
functions that have been queued up by AddDestructor in a FILO fashion
before exiting.