[Helpers] Fix a leak of file descriptors (#292).