You can exclude up to $250,000 ($500,000 if married) of gain from taxation when you sell your home. Your home, for this exclusion, is the place where you reside for a 2 year period out of the last 5 years.
Problems arise when you move out of your appreciated home and convert it to a rental. If you rent it for more than 3 years after moving out, then you no longer meet the 2-out-of-5 rule and will now need to pay tax on all of the price appreciation that your home has enjoyed since the day you bought it.
How can you preserve this valuable exclusion and convert it to a long-term rental?
Form an S Corporation and sell the home to the S Corporation within 3 years of moving out of the home. The sale triggers the gain to be recognized, and since you would meet the 2-out-of-5 rule, you can exclude the gain. You then have your S Corporation rent the property for whatever duration is necessary.