If you held residential house fo more than 2 years , then you surely get Section 54 benefits but before that you will need bank permission to release mortgage mark and repay the outstanding loan EMI's so that loan balance becomes zero.
Section 54 involves purchase of new residential house value of which is equal to more than LTCG from sale of old one.