Ensure the destroying order of static variables

To fix issue #52
I'd rather keep things Valgrind-clean.