Fixes bug in close_all_files()