The general rule is to never cancel an account which holds a number before the number is sucessfully in the new carriers system. Otherwise (usually) the number is put into pool to be reassigned after some waiting period.
What I have found is that you submit a request with the new carrier which includes the phone number, address of the number (that can be an issue by the way) and any pin associated with the number. I also believe at least for the numbers I have transfered, the process is automatic where the new provider tries to pull the number. If the data does not match, the pull is rejected.
A case I had was that the address for a landline number was not correct. In fact it was a virtual number and the losing phone company gave 2 different addresses (one being their central office); neither address worked and the porting failed multiple times. I finally opened a non-official complaint with the FCC who sent a request t othe losing telcom asking them why they could not make the port happen. Within a day or two the telco I guess manually allowed the transfer to take place.
I do know that there may be address and/or pin issues with virtual numbers, VOIP numbers, etc. However, the issues and solutions should be well-known to carries now-a-days.
My previous post on this type of issue: Tello.com - Failure to PORT in my phone number