Fix a crash on exit.