Sometimes, it’s necessary to end a contract early. However, a contract is in place to make sure both parties complete a deal, so getting out of it won’t be easy.

To help yourself avoid legal trouble, it’s a good idea to avoid signing a contract until you’re comfortable with the terms. A few tips to make sure you can end a contract in an emergency follow.

1. Add in or require a termination clause

The first thing to do is to make sure you put a termination clause in the contract. This adds a provision that allows you to get out of the contract if certain conditions are met. For example, rental contracts often have clauses that allow tenants to move out if they give enough notice for the landlord to find a new tenant.

2. Show that you’re unable to complete your obligation due to your circumstances

Called “impossibility of performance,” this is grounds for the termination of a contract when the reason you can’t complete a job is due to circumstances far beyond your control. For example, if you can’t complete a construction contract because of an accident resulting in your incapacity, then you may be able to get out of the contract legally.

3. Negotiate to get out of the contract

Finally, remember that you can try to negotiate to get out of a contract. If both parties can reach an agreement, then you can avoid litigation.

These are three tips for getting out of a contract legally, so you can avoid getting sued. Contracts are typically binding, but every contract should have clauses to allow you to end the contract, too.