This is a problem with Euler angles. As they go from 0 to 360 (or -180 to 180) then you will always have problems at the end of the range, especially when interpolating the value. Think of it like this, you want to rotate 30 degrees. But the angle is from 340 to 370 (or 10). If you just interpolate the values (340 and 10) instead of rotating 30 degrees, it will rotate 330 degrees, and in the wrong direction. You can account of this by looking at the values and adjusting them, but it is an inherent issue with using Euler angles.
A few things can help. First, try to always get 0 to 360 to make the math easier (so you don't get negative values or values above 360):
var angle = fmod(angle + 360.0, 360.0)
Then you can find the smaller angle. If you know your delta angle will never be more than 180 degrees (a pretty fair assumption for most games):
var angle_delta = angle - last_angle
angle_delta = fmod(angle_delta + 360.0, 360.0)
if angle_delta > 180.0:
angle_delta = angle_delta - 360.0