Added readlink on the pids to find which files to close.