If you pay the final payment.
You walk away or you pay the final amount.
if the car is worth a lot more, it makes sense to pay it and then sell it. If it's worth less, you hand it back. That's the beauty of a pcp as you always know where you stand and have no risk at the end, but you pay more for the security of being able to walk away.
It used to be that main dealers would value the car come hand back time, and give you the positive difference as a deposit towards the new car as an incentive to keep you in the brand, but I'm not sure they do that anymore.