Revert "Revert a7325792ce4bf0ac8300a010ec79bddc04475100 and 9a129f237fa7980c09d898740b70d81a1514b05c as they prevent the user from logging in with clean config"

This reverts commit aadbe648c8048f5e4717f3ceafab910fee313ce5.

Proper fix to follow.
SFR 460602 Improve previous fix - ensure any pending writes are written
prior to reloading the config from file.