Opinions expressed by Entrepreneur contributors are their own.

The housing market has slowed after a pandemic-induced frenzy, and real estate firms are trying to pivot in anticipation of a possible downturn. As mortgage interest rates rise and home sales continue to steadily drop, Redfin and Compass are cutting workforces by hundreds.

In filings with the Securities and Exchange Commission, Compass announced it will be cutting its workforce by 10% and Redfin by 8%, amounting to over 400 employees from each company.

Compass stock is trading at about 75% less than its price in 2021. As for Redfin, stock is down almost 92% since 2021.

Related: Redfin vs. Zillow: Which Online Real Estate Marketplace Stock is a Better Buy?

In a company-wide email sent by CEO Glenn Kelman, he shared remorse in the decision by writing, “I Said We Wouldn’t Lay People Off Unless We Had To. We Have To.”

Kelman carried on to emphasize that while they raised efforts to avoid massive layoffs, the rising interest rates position the market for “years, not months, of fewer home sales,” and that “if falling from $97 per share to $8 doesn’t put a company through heck, I don’t know what does.”

Redfin layoffs are targeting mostly user research and engineering positions. In his closing remarks, Kelman stated “I’ll spend the rest of my life wondering how I could’ve avoided these layoffs. What’s most important now is treating the people leaving with humanity and respect.”

Compass was less direct with news and elaboration on details of the layoffs. The company stated in the filing that “the strategic actions are part of a broader plan by the company to take meaningful actions to improve the alignment between the company’s organizational structure and its long-term business strategy.” Compass is also looking to cut costs by consolidating some offices.

Related: Never Let a Downturn Crush You