Make sure files are closed so this runs on Pythons without reference counting