core: Properly close config file