As far as gravity is concerned, there's little difference between a molecule of air, a rock or a planet. They all obey the same Laws of Gravitation. An object close to Earth will "feel" a force towards the center of the Earth of GMm/r² (where G is a constant, M&m are the masses of Earth and the object, and r is the distance between them). This means that if you throw a rock up into the air its vertical velocity will decrease, reach zero, and then it will begin to accelerate downwards. Same thing with an air molecule. Molecules of gas can pretty accurately be described as particles with varying velocities due to collisions between them; when two collide, one may be sped up, the other slowed down, but momentum (and energy) have to be conserved. Within about 10 miles of the surface of the Earth, for most purposes, it is accurate enough to approximate the force acting on a (small (relative to Earth's mass)) object as a constant, g. When talking about what is happening to gas molecules 100 miles above the Earth, that approximation isn't very good. As a molecule of gas rises away from Earth, the force of attraction between it and Earth is getting less and less, so any object given enough of an initial velocity will "escape" from Earth's gravity. But that velocity is pretty high, and few things are traveling that fast. (We ignore air resistance here, because for a molecule of gas, air resistance isn't relevant). Anyway, most of the gas molecules going away from Earth fall back; only a few have the velocity to escape. (There's also the Solar Wind which can "blow" some molecules away, but talking about that would mean talking about our ionosphere, and we'd get bogged down pretty quick...)