You are correct, sometimes it does not calibrate correctly and runs forever. If I restart the foc script, it usually gets it.
Now I have a new issue, possibly related to my current limited power supply. When the foc script enters closed loop mode, the motor stops, and locks the rotor.