Fixed crash on exit bug