Moving your pace is always a free action. From Savage Worlds Deluxe:
Characters may move their full Pace (usually 6” for humans) in a round. This is considered a free action and doesn’t inflict a penalty to any other actions, such as firing a weapon or taunting a foe.
(Emphasis mine). Note that when a character is Shaken, they can still move their Pace because when you are Shaken, you can only take free actions and this is a free action.
The rules for withdrawing from close combat are as follows:
Inevitably, your hero will decide discretion is the better part of
valor. Whenever a character retreats from melee, all adjacent
non-Shaken opponents get an immediate free attack (but only one—no
Frenzy or other Edges apply unless they specifically say otherwise).
Note that withdrawing isn't an action or anything, just an extra consequence if you are moving away (a free action) to get away from an enemy in melee. So you can still withdraw if you are Shaken.
The rules on withdrawing from melee also specifically draw attention to the Defend combat option (+2 Parry, but no other actions that turn). You can normally Defend at other points in combat as a regular action, but as a special case when you are withdrawing, you have the option to use the Defend action as you are retreating:
A character may take the Defend option (+2 Parry) while retreating from combat, but won’t be able to perform other actions that round besides movement and still suffers the free attack.
The benefit to using it as described above is that you would get +2 Parry against the free attacks against you. Using the Defend action in this situation is entirely optional (as affirmed by this official answer on the Pinnacle forums). So you can also choose not to use the Defend action and still take normal actions afterwards, provided you survive the free melee attack.