My Ender 3 V3 that I’ve had for over a year just recently started failing during levelling. The print head goes to the top and transits across, then goes down to the bed, It then starts to slowly work its way back up. When it gets to the top rail, it starts repeatedly banging against it as if it thinks iy should be able to continue up. But it stopped at the correct height earlier. I replaced the motherboard with no effect. Any suggestions?
I would begin by resetting the printer to factory defaults and performing the auto leveling test.
If it still occurs then you may have a failing x/z limit switch.
This vid might help you get a better idea. https://www.youtube.com/watch?v=Wvi39sIz6NQ&t=11s
I tried the reset. No luck.