Ensure file handles are closed in setup.py