A lease is term-specific, usually lasting one year. That means that you have agreed to live in the apartment for that period of time. If you need to move away for any reason, you may be held to the terms of your lease. A landlord can make you buy out your lease, for example. Let's say you have four months left on your lease, and you pay $1,000 in monthly rent. The landlord would then let you out if you paid the $4,000. Some leases have a "buyout clause," with a fixed, but likely high number, to void the lease. Landlords have also been known to let tenants out of a lease by holding onto the security deposit. In any event, check your lease agreement when you move in, so you know what you'd be facing if the time ever comes.
If the terms of the lease are violated, it often renders the lease invalid, allowing you to move out. A common version of this scenario is if a landlord repeatedly fails to make the repairs of the sort promised in the lease. Provided you can show a written record of repeated requests, followed by a reasonable amount of time for the landlord to make the repairs, you may be off the hook. Or if the city denies power or water to the complex due to the fault of the landlord, that's another case of failed promises.
If that lease is airtight, and neither party did anything wrong, you may be able to sub-lease the apartment to a new tenant. (Some states, however, don't allow this.)
A lease can also be terminated if the tenant fails to hold up his end of the agreement. To avoid that situation, pay your rent on time, and always keep things clean and civil.