When Rhiannon Leonard opened a letter that said she and her family needed to vacate their rental in 30 days, she felt betrayed. They’d lived in the house in Portland, Oregon, for more than two years—it felt like home.

Rhiannon didn’t know her landlords had been considering selling the place, so the letter came as a surprise. “They decided the market had changed, and the house wasn’t worth it for them anymore,” she says.

She, her husband, and their two sons started renting the house under a fixed-term lease, but after two years, the lease transferred to a month-to-month contract. Usually, a month-to-month agreement means both the landlord and the renter need to give each other 30 days notice if they want to terminate the lease. But in Oregon, landlords need to give renters 60 days notice if the renter has lived at the property for more than a year.

“We were uprooting our family, and we felt there was very little sensitivity to that fact,” says Rhiannon.

Many renters can relate. There’s never a good time to be told to leave your home, even when a landlord terminates a lease legally. But there are ways to protect yourself, starting with knowing your rights.

Document everything

Start by documenting every interaction with your landlord, from phone calls to emails. If you can, communicate on paper. Use clear and professional language; consider written communication legal documents.

Make copies of letters before you send them, and consider getting a “proof of mailing” by buying a Certificate of Mailing at the post office.

The Community Alliance of Tenants, an Oregon nonprofit, has more tips on how to thoroughly document interactions with your landlord, advice that applies to renters in every state.

Know what kind of lease you signed

There are two kinds of leases: month-to-month or fixed-term, and each one comes with different requirements for termination. Hopefully you signed a legally binding lease and have a copy of it. Learn more about leases and rental agreements, which are generally month-to-month contracts, here.

If you’re on a fixed-term lease

Just because your landlord is selling your place, doesn’t necessarily mean you need to move out. A fixed-term lease states you can stay until the end date, even if the property changes ownership.

In almost every state, the lease and security deposit must be transferred with the property, and the new owner becomes the new landlord.

There are a few reasons why you might have to leave earlier than the end date of your fixed-term lease. You may have violated the lease by doing any of the following:

  • Failing to pay rent
  • Engaging in illegal activities on the property
  • Violating a no-pet clause
  • Subleasing, if prohibited
  • Causing serious property damage
  • Being a nuisance to others
  • Falsifying information on your rental application

Your landlord might suggest paying you to leave the property before the lease’s end date, which is called “cash for keys.” They could offer the difference for comparable rentals in the area. Or they might offer to pay your moving costs or part of the security deposit on a new place. You’re under no obligation to agree to their terms. You can choose to stay until the lease end date, assuming you are not violating the lease somehow.

There are some cases in which a landlord will execute an “early termination clause” in the lease, which means they have the right to terminate the lease in 30, 60, or 90 days from the sale of the property or proof of a ratified sales contract. The catch is that you’ll need to agree to whatever “trigger” the landlord chooses, such as the landlord wanting to move into the house or sell it.

If you’re on a month-to-month

In most states, your landlord needs to deliver you a letter in the mail, by hand, or by posting it on your door. Usually, they need to give you 30 days to move out of the property, but the required notice period varies from state to state. Look up your state’s policy here.

Most states don’t require a landlord to give a reason to end a month-to-month contract, an agreement designed to let renters and landlords terminate the lease with short notice. If the renter didn’t do anything wrong, as with Rhiannon’s situation, it’s called “no cause termination.”

But landlords still need to tell you some things in writing, including:

  • The date of the letter and date they expect you to move out (XX days from the notice).
  • That you should remove your possessions and return the keys on or before the move out date.
  • A statement that if you don’t move out, they’ll begin the eviction process.

Buy the property

In some cases, your landlord might offer to sell you the property, which is great if you love the place and you’re ready to become a homeowner. If that’s the case, consider a seller financing arrangement, which is a type of transaction in which the landlord is the lender who will accept payments from you (on a short-term basis).

The gist

Unfortunately, no rental situation is permanent. Leases always end, landlords change their minds, and homes change owners, all of which makes long-term nesting difficult.

Fixed-term leases are the best way to secure your housing for a set period of time, regardless of who owns the property. Be sure not to sign away too many rights in your lease, and do your due diligence by researching your state’s rental laws.

For more information about your rights as a renter in your state, check out the U.S. Department of Housing and Urban Development’s resources.