Cleaning the machine

Please post it here as well as I still can’t understand what it is doing from your description. I thought it was just trying to move past the end of the X axis because it decides to go the wrong way. Is it something more than that?