On termination criteria for decoding algorithms