Set the preferences when closing the preferences dialog
Since many users simply close the preferences dialog thinking
their changes will be saved, apply the changes also when the
dialog is closed.
Now only the Cancel button will really close the dialog and
not set the changed preferences.