Make apply_deferred_settings more robust when it's being called
when exiting