(Bloomberg) -- Homeowners in the U.S. are holding on to their houses longer than they have in at least 18 years, and when they do sell, they’re reaping gains that haven’t been seen since before the housing crisis.

Those who sold in the second quarter did so after owning their homes for an average of 8.09 years, the longest stretch since Attom Data Solutions started tracking the statistic in 2000. The wait appears to be paying off: Second-quarter sellers recorded gains averaging $58,000 -- the most since the third quarter of 2007.

Seller gains reached their peak in the fourth quarter of 2005, when they averaged $89,780. They bottomed out less than four years later, in the first quarter of 2009, when the average seller lost $58,735.

To contact the reporter on this story: Jeremy Hill in New York at jhill273@bloomberg.net

To contact the editors responsible for this story: Daniel Taub at dtaub@bloomberg.net, Christine Maurus, Steven Crabill

©2018 Bloomberg L.P.