Fix possible crash on exit. Need to investigate reson