Fix a crash at exit.