Research studies confirm what we all know and understand intuitively: The end of an experience significantly affects the way we remember and evaluate the overall experience. That’s the logic behind the insistence on a happy ending in Hollywood movies or of dessert at the end of a meal. This principle – the immense significance of experiencing a positive ending – is reflected in every sphere of life, apart from one: Death.

Thanks to modern medicine and technology, however, the end of life, in almost every case, does not constitute its high point. On the contrary: It’s a low point. Many people today and most of us in the future will likely die in a hospital bed – in agony, bewildered and helpless. Experiencing fear and humiliation. Undergoing painful, unsettling procedures in order to gain a few more days of “life.” As it stands, our ability to influence the way we will end our life is negligible. And this is not just a sad way to end our life: It is also a terrible way to leave our memory for the loved ones we leave behind. What is clear is that the way we experience our final days, weeks and months are important for us and for our loved ones.

We arrived at this particular way of ending our life without planning. I can’t imagine that anyone would have constructed a system like the one we have if they planned it. But, we did get here. How? Health professions are focused on mortality and life expectancy measured by days – not on the quality of life. On top of that, death is not a fun topic to think or talk about so we rarely give thought to death. We prefer to repress and deny dealing with it, which eventually got us to where we are.

The terminal point in our life is determined by the axis of the progress being made by medicine and technology to keeping life at all cost, without any thought or attention being paid to the end of it. I hope that in the coming hundred years we will understand the damage being caused by this approach to our individual and collective quality of life, to human dignity, and the economic cost to society that we bear for not taking any steps to design and take control of the end of life challenge.

There are already many ways in which it’s possible to reconfigure the end of life. Hospice care – supportive care of symptoms that accords inner tranquility. Less resuscitation. Use of drugs and medication to fight pain, pressure and anxiety. A decision about the point at which our deteriorated quality of life, when we are struggling with death, does not justify the effort being invested, and we are better off devoting the time that remains to our dear ones.

But end of life is not just about the medical care we get. We can also try to spend our time taking into account what we have achieved, the things that have brought us pride and joy, instead of focusing on the fear and on counting the days and hours left in the dwindling sands of the hourglass of our life.

We can construct and shape the way we part from the world – on our terms, with dignity, while in control, in order to minimize mental and physical suffering. This is a complex, multifaceted challenge – socially, physically, financially, morally – but we are duty-bound to contemplate it and not avert our glance. In the coming hundred years, we will undoubtedly find many ways to improve our lives. But one of the most valuable contributions to life might be finding the way in which it is worthy to die.

Dan Ariely is a James B. Duke Professor of Psychology and Behavioral Economics at Duke University.