Close file streams to avoid fd leakage
Merge pull request #530 from krabaey/feature-close-files

Close file streams to avoid fd leakage