Hi,
Capital gain exemption can be claimed only for buying/constricting a house u/s 54. You cannot get capital gain exemption by using the money to pay off housing loan.
So, if you want to save Capital Gains tax, then invest the Gain amount up to Rs. 50 Lakhs in Capital Gains Bond. You can use remaining amount to pay off the loan.
Alternatively, you can pay the Capital Gain tax and then use all the remaining amount to pay off the Loan.
Or, you can use a combination of both the above options