An ordinary sale generally leaves the lease in place. The new owner takes over the landlord's obligations under it, and tenants do not have to leave just because the house sells. A sale and a decision to end a tenancy are separate questions.
If you want to end an ordinary month-to-month tenancy, the usual rule is written notice at least 28 days before the end of the rental period. The lease and the reason for ending the tenancy can change what is required.
When arranging closing, account for the lease, rent, and security-deposit balance. Bring the current lease and rent and deposit records into the closing discussion so the handoff can be documented.