In the tail-cap you will see a ring with two indentations in it, that is the retaining ring for the switch.
It is possible that the ring was not tightened properly, was cross threaded or worked loose causing the switch to loose contact with the flashlight when it is shaken. Your description of...