Prevent some segfaults when shutting down on Linux
Silence some valgrind complaints