To exclude gain, a taxpayer must both own and use the home as a principal residence for two of the five years leading up to the date of sale. The two years need not be consecutive.
The tax law provides an exception to the two-year rules for use, ownership and claimed exclusion when the primary reason for the sale is health, change in place of employment, or, to the extent provided in IRS regulations, “unforeseen circumstances.”
A sale will be considered as occurring primarily because of “unforeseen circumstances” if any of these events occur during the taxpayer’s period of use and ownership of the residence:
- death,
- divorce or legal separation,
- becoming eligible for unemployment compensation,
- a change in employment that leaves the taxpayer unable to pay the mortgage or reasonable basic living expenses,
- multiple births resulting from the same pregnancy,
- damage to the residence resulting from a natural or man-made disaster, or an act of war or terrorism, and
- condemnation, seizure or other involuntary conversion of the property.
https://www.irs.gov/uac/irs-issues-home-sale-exclusion-rules
**Answers are correct to the best of my ability but do not constitute tax or legal advice.