libqtest: only call fclose() on open files