Thank you for your help.
When I trigger the end stop switches manually, the machine does stop fine.
I notice that the X axis movement seems fine. But the Y axis motor seems to grind and not want to move.
When the machine is off, I can easily slide the print head in both axes.
I wonder if there is something wrong with the Y axis motor or wire for that motor.