Not every Landlord Tenant dispute has a positive outcome for the tenant. Landlords frequently prevail in Housing Court. For example, if you just can't come up with the money for back rent due, or the current rent, then no matter what steps you or your lawyer may take, sooner or later you will have to relinquish your rights to occupy the apartment.
That being said, if in consulting with your attorney you anticipate having to leave, there are several elements that can be negotiated to your advantage. Three examples, among others, are: what happens to the security deposit, the actual date of vacancy, and attorneys fees.
Landlords know that even if they win, it can be an extended period of time before they gain control of the unit. Your lawyer may be able to negotiate return of your security deposit and discontinuance of claims against you for payment of the landlord's legal fees, if you agree to move out earlier than otherwise.
There are of course situation-specific variables in every case, and whatever is agreed to will have to be properly documented in writing. However, one client who recently had to vacate her apartment was able to save $7,000 by effective negotiation, releasing her from a financial burden and making it easier to get resituated in a new place to live.