The projectivity of the moduli space of stable curves, II: The stacks $M_{g,n}$