To make us mindful of death, the Buddha taught meditation on death. If you are mindful of death, you will be drawn into thinking of many things, particularly whether there is life after death. Even if you suspect that there is, you will take interest in the quality of that life — what it might be like.
This will lead you to think about Karma, the cause and effect of action, thereby drawing you away from choosing activities of harmful nature and encouraging you to engage in activities that are beneficial. This itself will lend your life a positive purpose.
If you try to avoid even the mention of death, then on the day when death comes, you may be frightened. However, if you contemplate the fact that death happens naturally to all living beings, this can make a big difference. When you become familiar with death, you can make preparations for dying, and decide what you should do with your mind at that time. On that day your preparation will have its effect; you will think "Ah, death has come," and you will act as you had planned, free from fright.
The great Tibetan yogi, Jangchup Rinchen, had said, "Now is the time to make ourselves different from domesticated animals. It is meditation that makes us different from other species. Meditation on the imminence of death takes place by way of three root reflections, each of which is based on three reasons, leading to a decision. First, contemplate that death is definite; therefore, I must practise. Second, contemplate that the time of death is uncertain; therefore, I must practise now. Third, contemplate that at the time of death nothing helps except transformative practice; therefore, I will practise non-attachment.
Sometimes when people come to accept that they might die any time, they draw the mistaken conclusion that planning for this life is useless, and they do not accomplish anything. They forget that they have to engage themselves in welfare activities for their own and others' good.
(Edited excerpts from the writer's book, Becoming Enlightened.)