fix segfault at exit