Fixed segfault on application exit