It all really depends on your rental agreement. In my rental agreements, (those I draw up for my tenants) and the one I am currently under as a tenant, rent is due at the beginning of each rental period (each month) in my cases. The deposit is not to be used as a substitute as rent. Not paying rent in a timely manner can lead to additional charges. Your lease may vary.
There are several formal steps you should follow if you intend on moving out including giving your landlord written notification of intent to leave, doing a final walkthrough with your landlord in order to preserve as much of your deposit as possible. After you leave your should make sure your landlord delivers any and all documentation associated with any repairs that were made due to your tenancy. The deposit (less landlord expenses) shall be returned in a timely manner. Unfortunately you will be at a shortfall until the deposit is returned.