Legally speaking, you are responsible for the entire lease. So, if you have five months left on the lease, you are responsible for paying the rent for each of the five months. On the other hand, the security deposit must be returned to you upon completed payment of the entire lease, provided there's no damage.
In most cases, you are only responsible for paying the lease until the landlord can find someone else to move in. Indeed, this may actually be a legal requirement, and if you can show that the landlord refused to rent after you had moved out and informed the landlord that you had moved out, you will likely not be responsible for the rent going forward. That is, if you move out with five months left and someone else calls the landlord and tries to
move in, a month later, you will only be responsible for one month of rent. Note that you may have to sue, however, and would have to offer proof that the landlord refused to rent the empty apartment.
The best course of action is to talk to your landlord and see if you can terminate the lease early. Depending on the rental situation, the landlord may be willing to do this with sufficient notice and perhaps payment of a month or two of rent.
If you decide to simply skip out on your lease, the landlord will, in most cases, not bother actively trying to get the remainder of the lease payment from you, but will most likely put a valid black mark on your credit report if you abandon your lease and refuse to pay your obligation.