The runaway condition means two things to me: the encoder signal is missing or the phases of the encoder got accidentally reversed relative to the motor direction. I would disconnect the Z axis motor coupling to prevent running the axis to the end of travel, and then run another test, by reversing the leads to the motor and starting up the control again. If it holds position, then most likely improper hookup was the problem.
Of course, the motor needs to run in the correct direction, so then put the motor leads back the way they were, and interchange the A and B encoder connections.
This wiring mixup would only happen if you actually disconnected the leads and got them mixed up when reassembling everything. Perhaps you got some wires mixed up inside the motor when you replaced the brushes? If you disconnected nothing, and had this problem, then I would suspect the encoder is not putting out any signal (ie., it is dead for some reason).
First you get good, then you get fast. Then grouchiness sets in.
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)