Close file streams to avoid orphaned file descriptors