PID control loop exit condition
A PID algorithm corrects a control signal based on an error, and its goal is to reduce the error to zero. 

By 'turning' I understand that you want your robot to move to a required position or to a certain distance. In that case, the error is the distance that the robot has yet to cover, and the control signal could be the PWM duty cycle that power the motorized wheels.

Consider this pseudo-code:

requiredPosition = obtainRequiredPosition();
error = requiredPosition - currentPosition;
while(error &lt;&gt; 0) {
    correction = PID(error);
    averagePower += correction;
    applyPower(averagePower);

    // Wait a little: either with a waiting loop
    // or, better, implement the whole thing in iterrupts.
    wait();

    currentPosition = captureCurrentPosition();
    error = requiredPosition - position;
};


I don't think you need the integral part of the PID. You don't need your robot to spend an equal amount of time with positive and negative error.

As an example, you would need the integral part to control the helm of a boat: When the boat is heading in a specific direction, you want to compensate the time going too much to the left with an equal time going too much to the right.