Hi and welcome to the forum. The k40 has 2 optical endstops, x-axis and y-axis, that it uses to sense the home position of the head.
Your k40 is trying to home y first but the optical end stop for the y-axis is not engaging to tell the motor to stop turning.
The end stops have a U shaped price of plastic that holds a light emitter - light detector pair. For the y-axis this travels with the rail and a metal fin should slide into the U and block the light when it reaches the end of the travel.
You need to check and make sure the metal fin is not bent or blocked and slides to the U. Also check and make sure all the cables are firmly in place.
Could be a bad end stop, but check the things I mentioned and let us know what you find. If you need a picture let me know.