Drive Won't Stop When Turning When Using Shaft Encoders

Our Drive keeps turning and wont stop after it makes the turn. Any Suggestions??

#pragma config(Sensor, dgtl1,  sensorleft,     sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  sensorright,    sensorQuadEncoder)
#pragma config(Sensor, dgtl5,  solenoid,       sensorDigitalOut)
#pragma config(Motor,  port2,           FrontRight,    tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, dgtl3)
#pragma config(Motor,  port3,           FrontLeft,     tmotorVex393HighSpeed_MC29, openLoop, encoderPort, dgtl1)
#pragma config(Motor,  port4,           MobileRight,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           Lift1,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           Lift2,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           MobileLeft,    tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port8,           BackRight,     tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, dgtl3)
#pragma config(Motor,  port9,           BackLeft,      tmotorVex393TurboSpeed_MC29, openLoop, encoderPort, dgtl1)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(0)
#pragma userControlDuration(60)


#include "Vex_Competition_Includes.c"


void Drive(int distance, int power)

{
	{
		SensorValue[sensorleft] = 0;
		SensorValue[sensorright] = 0;

		while((distance > 0 && SensorValue[sensorleft] < distance)||( distance < 0 && SensorValue[sensorleft] > distance))

		{
			if(SensorValue[sensorright] > SensorValue[sensorleft])
			{
				motor[FrontLeft] = power;
				motor[BackLeft] = power;
				motor[FrontRight] = power * (8.0/10);
				motor[BackRight] = power * (8.0/10);
			}
			else if(SensorValue[sensorright] < SensorValue[sensorleft])
			{
				motor[FrontLeft] = power * (9.0/10);
				motor[BackLeft] = power * (9.0/10);
				motor[FrontRight] = power;
				motor[BackRight] = power;
			}
			else if (SensorValue[sensorright] == SensorValue[sensorleft])
			{
				motor[FrontLeft] = power;
				motor[BackLeft] = power;
				motor[FrontRight] = power;
				motor[BackRight] = power;
			}
		}
		motor[FrontLeft] = 0;
		motor[BackLeft] = 0;
		motor[FrontRight] = 0;
		motor[BackRight] = 0;
	}
}

void turnLeftDeg(int degrees, int power)
{
	//Reset encoders
	SensorValue[sensorleft] = 0;
	SensorValue[sensorright] = 0;

	//Determine tickGoal
	int tickGoal = (23 * degrees) / 10;

	//Start the motors in a left point turn.
	motor[BackLeft] = -1 * power;
	motor[BackRight] = power;
	motor[FrontLeft] = -1 * power;
	motor[FrontRight] = power;

	//Since the wheels may go at slightly different speeds due to manufacturing tolerances, etc.,
	//we need to test both encoders and control both motors separately. This may result in one motor
	//going for longer than another but it will ultimately result in a much more accurate turn.
	while(SensorValue[sensorright] < tickGoal || SensorValue[sensorleft] > -1 * tickGoal) {
		if(SensorValue[sensorright] > tickGoal) {motor[BackRight] = 0;}
		if(SensorValue[sensorleft] < -1 * tickGoal) {motor[BackLeft] = 0;}
		if(SensorValue[sensorright] > tickGoal) {motor[FrontRight] = 0;}
		if(SensorValue[sensorleft] < -1 * tickGoal) {motor[FrontLeft] = 0;}
	}
	//Make sure both motors stop at the end of the turn.
	motor[BackLeft] = 0;
	motor[BackRight] = 0;
	motor[FrontLeft] = 0;
	motor[FrontRight] = 0;
}



void pre_auton()
{
}


task autonomous()
{

	turnLeftDeg( 90, 50);

}

task usercontrol()
{

	while (true)

	{

		motor[FrontLeft] = vexRT[Ch3];
		motor[BackLeft] = vexRT[Ch3];
		motor[FrontRight] = vexRT[Ch2];
		motor[BackRight] = vexRT[Ch2];




		if (vexRT(Btn5U)==1)
		{
			motor[MobileRight] = 120;
			motor[MobileLeft] = 120;
		}
		else if (vexRT(Btn5D)==1)
		{
			motor[MobileRight] = -100;
			motor[MobileLeft] = -100;
		}
		else
		{
			motor[MobileRight] = 10;
			motor[MobileLeft] = 10;
		}
		if(vexRT[Btn8R] == 1)
		{
			SensorValue[solenoid] = 1;
		}
		else if(vexRT[Btn8D] ==0)
		{
			SensorValue[solenoid] = 0;

		}
	}
}

Make sure that your shaft encoder works using the debugger window after you download.

our encoder was backwards