The key word is willingly
As you quote, the rule about movement says
Whether a creature is a friend or an enemy, you can’t willingly end your move in its space
"End" even extends to a short stop to do something, before moving on.
In summary can you end your move in another creature's space?
- You can if you did not move willingly
- You can if your DM allowed you to climb upon a bigger creature
- You cannot by grappling or hiding
- You cannot by running out of movement
Unwilling movement
There are many ways you can end your turn in another creature's space, all of which work by not you moving willingly, but someone else moving you, you moving unwillingly, or you being stopped there. For example:
- You can be shoved into another creatures space
- You can be teleported into another creatures space
- You get pulled into the other creatures space, for example by Thorn Whip
- You can be enlarged or polymorphed to become larger and overlap with another creatures space
- You are stopped that is, your movement is reduced to zero by someone else, while you are in another creature's space
- You fall unwillingly into a pit that contains another creature
- You get engulfed by a Gelatinous Cube
- You are swallowed by a Purple Worm
- ... and so on ...
In nearly all of these cases, once you can act again, you likely need to move out of the creatures space if you can, or it out of yours, if its turn happens first, although this is up to DM adjudication. (The main question is do you "end your move" in its space if you do not move at all?)
Climbing onto a Bigger Creature
The only exception to this rule I am aware of is the optional action Climb Onto A Bigger Creature (DMG, p. 271), which allows you to willingly share a space with a bigger opponent by climbing onto it:
If it wins the contest, the smaller creature successfully moves into the target creature's space and clings to its body. While in the target's space, the smaller creature moves with the target and has advantage on attack rolls against it.
The smaller creature can move around within the larger creature's space, treating the space as difficult terrain.
Running out of movement
You cannot take actions, if they would leave you ending in another creatures space, so you cannot "run out of movement", and if your move would lead to such an outcome, your DM can ask you to reformulate how you move, or retcon what happend (if there already were opportunity attacks etc.).
Grappling and Hiding
Grappling in 5e will not let you share a space with the grappled creature, all it does (PHB p. 195, Grappling) is to subject the target to the grappled condition, which sets its speed to 0 and makes it impossible for it to benefit from a bonus to speed. It by default still stays in the adjacent space.
Hiding (on p. 177 PHB) is achieved by a Dexterity (Stealth) check, it has nothing to do with moving. There are rules how moving towards opponents in combat might blow your hidden status, but there is nothing whatsoever about moving into another creature's space, so this won't help.