Concur, it is usually the shock that loosens it. In fact I would not use a mallet but a hammer. Steel on steel, with nothing to soften the jolt. Even a shot-filled mallet often has too much cushion effect, though by all means try it first, and then move up to a 32oz. hammer! You might find the sheet metal tube socket you have shown is not up to the task. They are rarely heat-treated and tend to revert to round tubing under duress. A proper deep hex socket, 1/2 inch drive, with a breaker bar for a handle (not a ratchet handle) is best. Even better is a electric or pneumatic impact wrench, as used for removing wheel lug nuts on cars.
Do not put the nut back on with the impact wrench. It does need to be dead-tight, but there is a definite risk of over doing it with the impact wrench and stretching the threads. If you know what you are doing you can use a lower power setting, but the safe bet is to tighten manually. That way you have a feel for how tight the nut is.
-Doug