fix settings file could be left opened in rare circumstances