Fix detecting the end of movements for NPCs.