fix fix compile
fix possible crashes on exit