Fixed the object deletion race that used to occur only under gdb on windows builds.