He did not realize that if he had stood in one spot long enough, the shadow would have disappeared because of the sun – it would be underneath him when the sun was directly overhead.
What you realize here is he was trying to run away from his own emotion and was not in control of his emotions. Hence he was unable to think. Even in times of disparity, you need to be stronger, keep yourself together and not give into the situation. Else the situation will be in control and not you. You have to tell yourself that you are the one in control, which you will start believing soon, and eventually you will be in control of your emotions and in turn of the situation in hand.