After you renew your old passport, your old passport should be returned to you with holes punched in (at least for USA passport holders). When you leave the foreign country, bring both passports with you to the airport, so the immigration official will see your valid visa stamp on your old passport, and he/she will update your new, blank passport with the exit stamp.