Fix crash on exit and new settings applaying