This has everything to do with the order of destruction of objects with static storage duration. Function level statics, file level statics, and global variables all contribute. The problem happens when the corresponding LeakDetector object for a particular class gets destroyed while there are still instances of that object with static storage duration.
The only meaningful solution to this problem, which Jules objects to, is to stop using objects with static storage duration. I have created a class called a SharedSingleton which solves this problem completely. But it requires that all objects in the system use the SharedSingleton instead of a file, function, or global variable.
The SharedSingleton works together with the PerformedAtExit class to make sure that all the singletons are destroyed before the leak checking counters.