This function periodically checks whether Autopilot is finished and returns only after it is.
Useful links