Second attempt at fixing saving settings on shutdown.