The dynamics of a rapidly escaping atmosphere: Applications to the evolution of Earth and Venus