Spirited New Zealand end Pakistan tour with a 47-run victory in last ODI