Two separate issues:
1. Finishing a contract early - no problems, as long as you pay off the remaining line rental. They will give you a PAC code.
2. Using the PAC code on an existing contract - depends on network, some (like Vodafone) say you can only use it within the first 30 days, others (like Orange) don't mind when you use the PAC code at all. You'll need to ask the network that you want to take your number to.