It happens to me a lot, and I cannot understand why. I fix it by adding the same keyframe (rotation 0 for example) after the first one I want to remain still and before the last one.
Something like:
Keyframe 1
(rotation) xy&z = 0
Keyframe 2
(rotation) xy&z = 0
Keyframe 9
(rotation) xy&z = 0
Keyframe 10
(rotation) xy&z = 0
Sometimes It works adding just one of those keyframes, sometimes adding both, sometimes it just screws up
