If one corporation sells out to another, it's often possible to structure the deal as a tax-free reorganization. This means that essentially no capital gains tax is due at the time of the sale, because each party is merely exchanging one type of security for another. The big catch is that you must agree to accept stock in the other company as virtually the only consideration for the sale. This is risky, but aside from structuring the deal as an installment sale, a reorganization is really the only way to push the capital gains on the sale of your company into the future.
While these types of deals are most attractive with large public companies whose stock is highly liquid, it's also possible to do a merger between two private companies. You will, however, need expert tax and legal representation.