A study of the influence of plasma–molecule interactions on particle balance during detachment