Fixing bug where the preferences file was being over written when exiting the application.