Try using CloseSTDLIB() in your destructor.This is what the SDK says:
Link against: estlib.lib
Frees the thread-local storage acquired by the STDLIB DLL.
Data allocated in the thread-local storage for
STDLIB's DLL (the _reent structure) is not automatically cleaned up
when the environment is destroyed, and must be cleaned up
by the user of STDLIB. Call this function after the point at which
it is known that code in STDLIB's DLL will no longer be called and its
thread-local storage no longer needed.