Fixed saving of preferences on application exit