In my country, me moving out and saying I won't continue to pay, while the contract end date is still far in the future would of course be a breach of the contract. But that doesn't mean the landlord then can let the house sit empty for the rest of the contract time and force me to cover their loss. Landlord would instead have to try and minimize their losses by finding a new tenant, and what I would owe the landlord would be their costs to do so and the time the apartment stood empty.
Edit: "mitigation of damage" might be the US term for it. From Cornell: The mitigation of damages doctrine, also known as the doctrine of avoidable consequences, prevents an injured party from recovering damages that could have been avoided through reasonable efforts. The duty to mitigate damages is most traditionally employed in the areas of tort and contract law. To me that reads like if you want to void the contract, and the landlord doesn't accept a reasonable tenant to take over, the landlord might have to carry their losses themselves. My guess (given laws about renting being very in favor of tenants) is that there most places even might be explicit laws allowing the tenant to do this.