Close open file handles in files library

ref #10392 
cc @icewind1991 

I tested this locally, but the file handle count still increases