Excerpt from http://www.accesstoinsight.org/lib/authors/gunaratna/wheel102.html:
"This contemplation of death is one of the classical meditation-subjects treated in the Visuddhi Magga which states that in order to obtain the fullest results, one should practice this meditation in the correct way, that is, with mindfulness (sati), with a sense of urgency (samvega) and with understanding (ñana).
For example, suppose a young disciple fails to realize keenly that death can come upon him at any moment, and regards it as something that will occur in old age in the distant future; his contemplation of death will be lacking strength and clarity, so much so that it will run on lines which are not conducive to success.
How great and useful is the contemplation of death can be seen from the following beneficial effects enumerated in the Visuddhi Magga: — "The disciple who devotes himself to this contemplation of death is always vigilant, takes no delight in any form of existence, gives up hankering after life, censures evil doing, is free from craving as regards the requisites of life, his perception of impermanence becomes established, he realizes the painful and soulless nature of existence and at the moment of death he is devoid of fear, and remains mindful and self-possessed. Finally, if in this present life he fails to attain to Nibbana, upon the dissolution of the body he is bound for a happy destiny."
Thus it will be seen that mindfulness of death not only purifies and refines the mind but also has the effect of robbing death of its fears and terrors, and helps one at that solemn moment when he is gasping for his last breath, to face that situation with fortitude and calm. He is never unnerved at the thought of death but is always prepared for it. It is such a man that can truly exclaim, "O death, where is thy sting?"