Your friend is absolutely right. Unfortunately, this is how real estate market operates here.
Speak with Landlord. Tell him 60 days in advance before you want to vacate the apartment. Only Landlord can tell you what to do in this matter. If he says that you will be given a penalty of 3 months rent and refuses to return your cheques, then suggest that you will try bringing in replacement tenant. This happens a lot here.
Another option is if he refuses to return your cheque, then approach a lawyer and take their consultation. You will definitely lose money but atleast you dont want complications during your travel.
Wish you best of efforts.