ENH: close open file in a test