fixed issue with crash on exit