During safe Z homing, the line

#define XY_TRAVEL_SPEED 8000

is used from Configuration.h If the speed of the motors was too high for them to move where they are being told to go to, it is possible for the firmware to think the extruder is in a different place than it is.