Destructors for objects with a static lifetime (all cases when you specify objects with a static lifetime, although I do not think that an object in constexpr can have a non-trivial destructor): exit() called from the inside, the objects were built in the reverse order.
Returning from main calls exit to call with the return value, so returning from main will cause these destructors to be called. Other means of terminating the program ( abort() , denial of approval, _exit() , etc.) will not be called destructors.
If the objects are in a DLL ( .so under Unix), destructors will usually be called when the DLL is unloaded.
source share