Illustrative example
A fire leaves an apartment unlivable. The tenant moves out the same week, and the landlord bills for the eight months left on the lease.
Where a building is destroyed or so injured by the elements or any other cause as to be untenantable and unfit for occupancy, and this happened without the tenant's fault or neglect, the tenant may quit and surrender and is not liable for rent for the time after the surrender. Two conditions sit in that sentence, and both decide cases: fault, and whether an express agreement to the contrary was made in writing.
They agree the tenancy ended on the day the keys came back, apportion the advance rent to that date, and the deposit is returned in full.