Initially it makes sense to pay your mortgage off in the shortest time possible.
Consider
300,000 20 yrs 5%
Monthly Repayment:1,980
Total Interest Payable:175,168
------------------------------
300,000 30 yrs 5%
Monthly Repayment:1,610
Total Interest Payable:279,770
------------------------------
Now it looks like you'll pay 104,602 in extra interest if you choose a 30 yr term over the 20 yr one. But this doesn't take into account the time value of money. Paying 1,610 a month in Year 30 will take less resource than the same amount in Year 21 for example.
So the question is how do you calulate the real cost of a 20 Year term versus a 30 year term?
104,602