Rotate slowly from one PointA to pointB using radians

I have an object at Point A (with an angle) when i click on Point B i want the object to rotate slowly towards point B, using the closest side (cw or ccw). It’s running at 30 fps with a turnRate of 0.05.

I have this sketch so far: https://editor.p5js.org/Marcel0024/sketches/BJWp9jtR4

The problem i have is when once the object loops 180 degrees it just keeps looping it doesnt detect the stop.

I don’t have a good enough graps to figure the angles out, where i suspect the problem is