atan2 has nothing to do with it. At least not based on anything you said.
The difference between angles can exceed the range you want it to live in. So use mod instead. That is:
e = mod(e,2*pi);
e = e - 2*pi*(e > pi);
So, mod insures the angle will always live in the interval [0,2*pi]. It did that by effectively adding multiples of 2*pi. Then, if the number fell in the upper half of the interval [0,2*pi], I subtract 2*pi. The result will now always live in [-pi,pi].