Free some memory properly on shutdown.

This patch implements proper freeing of memory held in global STL containers.  While this only affects program shutdown anyway, I believe that it is cleaner to do it than to simply let the memory get lost, and it also prevents false positives when checking for memory leaks with valgrind.  With this patch applied, it shows no "definitely lost" memory any more.