Fixed segfault when quitting