Fix a crash on exit error