Can an insurance company not renew policy because house is for sale?

My homeowners insurance notified me that they would not be renewing my policy because my house is on the market. Has anyone ever heard of this? Can they actually not renew the policy for that reason?

My Mom had to get very costly “gap” insurance after she moved to assisted living and before the house sold.

I understand that homeowners insurance can be cancelled if a house is vacant. Maybe that is the reason for the cancellation and not necessarily because it is for sale.