Its possible that the ship has hit the 180/-180 threshold and is stuck moving between going +pan/-pan. I've had trouble with using "ang" before.

However there is a very good solution to shortest angle rotation here:

http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=201834

Yuo can also use testDummy's (thanks to him by the way) even shorter version of that:

var rotSp[3] = 20, 0, 0; // rotate speed
var vec_to_target[3];
var ang_to_target[3];

vec_diff(vec_to_target, player.x, my.x); // direction vector from my to you
vec_to_angle(ang_to_target, vec_to_target); // get angles of direction vector
temp[0] = ang(ang_to_target.pan - my.pan);
my.pan += min(rotSp.pan * time_step, abs(temp[0])) * sign(temp[0]);

Hope this helps.