Move into nonhostile space attack and move

Moving Around Other creatures

You can move through a nonhostile creature’s space [but] you can’t willingly end your move in its space.

Is that “end your move” at the end of your turn or if you stop to attack? I had a player who wanted to move into another friendly character’s space, attack a hostile, then sidestep behind a wall.