Some time ago I have encountered a problem during application startup that I could not lock mutexes from below DllMain(): C++11 std::mutex in Visual Studio 2012 deadlock when locked from DllMain(). I have worked around as mentioned in the accepted answer.
Now I am having a similar issue but this time caused by process shutdown:
KernelBase.dll!RaiseException() Unknown
msvcr120d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 154    C++
msvcr120d.dll!Concurrency::details::SchedulerBase::SchedulerBase(const Concurrency::SchedulerPolicy & policy) Line 155  C++
msvcr120d.dll!Concurrency::details::ThreadScheduler::ThreadScheduler(const Concurrency::SchedulerPolicy & policy) Line 26   C++
msvcr120d.dll!Concurrency::details::ThreadScheduler::Create(const Concurrency::SchedulerPolicy & policy) Line 34    C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CreateWithoutInitializing(const Concurrency::SchedulerPolicy & policy) Line 285  C++
msvcr120d.dll!Concurrency::details::SchedulerBase::GetDefaultScheduler() Line 654   C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CreateContextFromDefaultScheduler() Line 571 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CurrentContext() Line 399    C++
msvcr120d.dll!Concurrency::details::LockQueueNode::LockQueueNode(unsigned int timeout) Line 619 C++
msvcr120d.dll!Concurrency::critical_section::lock() Line 1026   C++
msvcp120d.dll!mtx_do_lock(_Mtx_internal_imp_t * * mtx, const xtime * target) Line 67    C++
msvcp120d.dll!_Mtx_lock(_Mtx_internal_imp_t * * mtx) Line 154   C++
log4cplusUD.dll!std::_Mtx_lockX(_Mtx_internal_imp_t * * _Mtx) Line 68   C++
log4cplusUD.dll!std::_Mutex_base::lock() Line 42    C++
log4cplusUD.dll!log4cplus::thread::Mutex::lock() Line 80    C++
log4cplusUD.dll!log4cplus::thread::SyncGuard<log4cplus::thread::Mutex>::SyncGuard<log4cplus::thread::Mutex>(const log4cplus::thread::Mutex & m) Line 208    C++
log4cplusUD.dll!log4cplus::spi::ObjectRegistryBase::clear() Line 113    C++
log4cplusUD.dll!log4cplus::spi::FactoryRegistry<log4cplus::spi::LocaleFactory>::~FactoryRegistry<log4cplus::spi::LocaleFactory>() Line 156  C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::DefaultContext::~DefaultContext() C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::DefaultContext::`scalar deleting destructor'(unsigned int)    C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::destroy_default_context() Line 90 C++
log4cplusUD.dll!log4cplus::thread_callback(void * __formal, unsigned long fdwReason, void * __formal) Line 457  C++
log4cplusUD.dll!DllMain(HINSTANCE__ * hinstDLL, unsigned long fdwReason, void * lpReserved) Line 480    C++
log4cplusUD.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 508  C
log4cplusUD.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 473   C
ntdll.dll!LdrShutdownProcess()  Unknown
ntdll.dll!RtlExitUserProcess()  Unknown
msvcr120d.dll!__crtExitProcess(int status) Line 776 C
msvcr120d.dll!doexit(int code, int quick, int retcaller) Line 679   C
msvcr120d.dll!exit(int code) Line 426   C
timeformat_test.exe!__tmainCRTStartup() Line 662    C
timeformat_test.exe!mainCRTStartup() Line 466   C
kernel32.dll!BaseThreadInitThunk()  Unknown
ntdll.dll!RtlUserThreadStart()  Unknown
The exception that it is raising is scheduler_resource_allocation_error. It is caused by failure of RegisterWaitForSingleObject() call.
The previous workaround will not help. I would have to be able to globally disable locking for all mutexes in various classes.
How the hell am I supposed to use C++11 threading and synchronization facilities if the Visual Studio 2013 does not let me clean up at process exit?