A sale does not end a tenancy at will, and the terms of a written lease still matter. When a tenancy at will transfers, the buyer becomes the landlord. At sale, the security deposit and accrued interest transfer to the buyer; the seller credits the buyer for prepaid last month's rent and its accrued interest. The buyer must tell each tenant in writing within 45 days that it now holds the money. Interest is 5% a year or the lower amount the bank actually paid.
You don't always need to evict to sell to us. We buy houses with tenants in place — we've done it many times, including cash-for-keys when that works better for everyone.
Massachusetts tenancy-at-will sale law ↗Security-deposit and prepaid-rent law ↗