Close settings files and save them correctly