Machine stops Homing

Machine will start homing cycle and move fast. then it slows down and some times will even stop before it gets to the limit switch and finish cycle. how do i fix this. i use UGS and have to hit homing 4 times to get it to complete