Uncertainty quantification for iterative algorithms in linear models with application to early stopping