Daily bit(e) of C++ | std::exit, std::atexit
Daily bit(e) of C++ #414, Executing custom code during normal program termination using std::atexit.
During normal program termination, any registered callbacks using std::atexit are executed as part of the cleanup. The callbacks follow the initialization and destruction rules from C++11.
For example, if a construction of a static object was ordered before a callback is registered, the destruction of that object will be sequenced after the callback is invoked.