If the gravitational attraction of all the matter in the observable horizon is high enough, then it could stop the expansion of the universe, and then reverse it. The universe would then contract, in about the same time as the expansion took. Eventually, all matter and energy would be compressed back into a gravitational singularity. It is impossible to ask what would happen after this, as time would stop in this singularity as well.
For this to happen, the average denisty of matter in the Universe has to be so high, that the overall space-time curvature of the Universe is positive, like the surface of a sphere. If the matter density is less than certain value, called the critical density, the curvature is negative (like a hyperbolic surface, which is a mathematical manifold often compared to the form of a saddle) and gravitation will be to feable to completly counter gravity, so that expansion will ever slow down but never come to an end. These two cases, and the limiting case in between, are called the 3 Friedmann modells. They assume the cosmological constant to be zero.
However, recent experimental evidence (namely the observation of distant supernovae as standard candles, and the well-resolved mapping of the cosmic microwave background) have - to most scientists' considerable surprise - shown that the expansion of the universe is not being slowed down by gravity, but instead, accelerating. (This evidence is considered conclusive by most cosmologists since 2002.)
In the framework of the field equations of the General Theory of Relativity this corresponds to a non-zero value of the cosmological constant, which again means the existence of a mysterious substance or field or force or property of the vacuum itself exerting a negative pressure that counters gravity on large scales.
See also the Big Rip.