A common way to defer taxes is through an installment sale, in which the buyer of the company agrees to pay payments over a certain number of years. Through this method you net profit percentage is calculated at the beginning of the transaction and you then only recognize income on the percentage of the gain you are paid for each year. You also have to report imputed interest each year. The benefit of this method is that in addition to deferring recognition of the gain, you are also taxed at a lower rate each year so you might not get pushed into the 20% long-term capital gains tax rate. The primary disadvantage is that you face the risk of default by the buyer.
Another method is to structure the sale as a sale of S corporation stock. Many buyers seek to simply purchase the assets of the corporation, relieving themselves of any unrecorded liabilities of the corporation as well as stepping up the basis of the assets (assets can be marked up to fair market value and depreciated). The disadvantage to you, as a S corporation shareholder, is that all any depreciation you claimed would be subject to recapture on the assets included in the sale. For example, if you have a bulldoser purchased for $75K and you claimed $75K of depreciation on it, and its FMV at the time of sale is $40K, you will have to recapture $40K of depreciation as ordinary income. In addition, if the property where depreciation was claimed is real property (buildings, land improvements, etc.), the depreciation is recaptured at a preferential rate, though still higher than normal capital gains rates.
If you do sell the assets, you will not want to distribute to yourself any asset that has a built-in loss. For example, say the bulldoser purchased for $75K only had $20K of depreciation claimed but is still worth $40K, but the buyer has not use for a bulldoser. If you do not sell the bulldoser to an unrelated third party, you will not be able to recognize the $15K loss (75-20-40).
Let me know if I can clarify anything or answer any additional questions.