Inertial Sensor Loop

We just added an inertial sensor onto our robot but when we turn the robot the inertial sensor makes the robot spin in the same direction infinitely until we stop the code.
This is the code were using right now.