A sale does not by itself end the lease or give you vacant possession. North Dakota lists when a lease ends: its term expires, both sides agree, the tenant gets title to the property, or the property is destroyed. A sale is not on that list. The buyer takes over as landlord and gets the same rights to collect rent and enforce the lease that you had. See North Dakota Century Code §§ 47-16-14 and 47-16-28.
Either side may end a month-to-month tenancy with at least one calendar month's written notice, unless the parties agreed in writing to a longer notice period or a different notice time. If a fixed-term lease has turned into month-to-month, the notice must end on the last day of a month. A fixed-term lease and other legal protections may require a different approach. See North Dakota Century Code § 47-16-15.
When ownership changes, the security deposit and the interest it has earned must be transferred to the buyer. You remain responsible for the deposit until it is transferred. The deposit is generally limited to one month's rent, with exceptions. Whoever owns the house when the tenancy ends must return the deposit, minus lawful deductions listed in writing, within 30 days after the lease ends and the tenant moves out. See North Dakota Century Code § 47-16-07.1.
The lease, written agreements, occupancy, and actual notice history affect what applies to one tenancy. Keep every lease and deposit record for the closing discussion; do not treat the sale date as a tenant move-out date.