When we calculate escape velocity, we set the total energy equal to zero. That is equivalent to setting the curvature term in the Friedmann equation to zero:
\frac{k c^2}{S^2} = 0 \nonumber
The Friedmann equation then becomes:
H^2 - \frac{8 \pi G \rho}{3} = 0 \nonumber
The only two adjustable quantities in the equation now are ρ, the average density of the Universe, and the expansion rate, H. Solving for ρ in terms of H we get:
\rho_{crit} = \frac{3H}{8 \pi G} \nonumber