[settings] implement OnSettingsUnloaded, fixes various advancedsettings leaking from profile to profile (e.g. mysql database config)
Merge pull request #4254 from jmarshallnz/onsettingsunloaded

Implements OnSettingsUnloaded