Ensure the destroying order of static variables

To fix issue #52
@dominichamon It would be much simpler if use pointer instead of static variable, but that will also result in a memory leak. (it's actually not a big deal, just ```valgrind``` prints junk) Do you have any idea?