Fixed bugs when exiting. Weeeeee