Flush changed preferences immediately

TBR @gaurave

This addresses the common problem of preferences not saved when the user exits CDE too quickly after changing them. This also improves CDE debugging. I've left some negligible delay to still allow some degree of bundling, when several settings are changed programmatically in one place.