All speed runs are considered done when the player reaches a point where he must not press any buttons to proceed.
So yeah, as soon as you've hit Bowser's head with the MechaKoopa, you do not have to press anything anymore to get to the "The End" Screen, leading us to the conclusion that the run is over when the Sixth MechaKoopa hits Bowser.
Which is obviously impossible to reach in 5 minutes, unless a drastic shortcut is found.