I was talking about the Galil plugin. It is not written by Galil or Mach. It is written by several (primarily two, me and Kenny Crouch) people. But others have helped out.
Mach uses the encoder as input. But only if it is synchronized. Mach is not ever controlling the PID loop. That is done on the Galil. Mach is a trajectory planner. The way it works is the position is fed into Mach from the Galil and the planner's position is set to that (synched). Then the G code is interpolated and a trajectory is planned FROM that initial agreed upon position. This is what is fed to the Galil for motion input. If that trajectory is not followed by the Galil, there will be a position error and Mach and Galil will have differing opinions of the machine position. It should be detected on the Galil if it is running analog servos with feedback. However, depending on Galil settings, it may not be setup to do much of anything regarding a position error. Mach's planner never re-plans based on a position error. If you do a G01 X1 from X1 and your PID settings are not adequate and the destination is never reached, Mach is not going to re-plan the trajectory and give it a bump to get it there. Why? Because it should not have to. The PID problem should be solved.
I like to use a car and driver analogy. Say you want to drive to the stop sign at the end of the street. You plan your route (trajectory). The route involves stepping on the gas, traveling for a distance, and then hitting the brakes. Then you get in the car and follow that route/trajectory. If you stop 30 ft. in front of (or beyond) the stop sign, is the route/trajectory wrong? No. You, the driver, need your PID/head examined!

Because you did not follow the route/trajectory. The route/trajectory had all of the information in it needed to get you to your destination. As a unit of work, it is complete. Nothing else needed. This is how all motion control systems work. Fanuc, Fidia, even EMC.
I will say this and every now and then people will tell me I'm wrong. They will say that EMC will re-plan the trajectory. It does not. What it is doing is the motion control aspect of EMC (the real-time component) is adjusting the command voltage based on the output of the PID filter looking at the following error. If the PID settings are not correct, EMC may never reach it's destination either.
You can never have a situation where you tell a motion controller to move 15000 counts, oops I didn't get there, move another 1000 counts for a total of 15000 counts. Because you have really asked the motion controller to move 16000 counts!!!!
So Mach, being just a trajectory planner, should NEVER be involved in closing the position loop because it is NOT a motion controller. EMC is a trajectory planner AND a position loop motion controller. It uses no real-time to plan the trajectory. However, it does use the real-time component to follow the preplanned trajectory. The Galil is the real-time component in the Mach/Galil combination so it has the same duties as the real-time component of EMC.
CNCToolDie's observation was that when hitting stop, the Galil plugin effectively lies to Mach about where the machine position is thus creating a discrepancy between what Mach thinks the position is vs. where the machine actually is. This is pretty much unrecoverable at this point. Only resetting the fixture offset or re-homing the machine will correct it.
Steve