ensure yaml file is closed