In Charles Dickens’s much beloved novella A Christmas Carol, the curmudgeonly Ebenezer Scrooge is unmoved when the Ghosts of Christmas Past and Present show him how his cruelty and selfishness have harmed others. Only when the Ghost of Christmas Yet to Come brings Scrooge face-to-face with his own impermanence in the form of his tombstone does the old miser begin to show benevolence and compassion toward others.

The coronavirus pandemic has brought all of us a lot closer to our impermanence. Faced with news photographs of makeshift morgues and dire headlines reporting body counts, we see that all of us, from Tom Hanks to Boris Johnson, are vulnerable—a fact that we push out of our minds in less threatening times.

But our reactions to this heightened sense of mortality can be dizzyingly inconsistent. We’ve seen amazing examples of people stepping up to help others during the pandemic: from a 99-year-old army veteran who raised $33 million for the U.K.’s National Health Service by walking laps in his garden to a royal milliner who started making face shields for hospital workers. On the other hand, we have also seen people stockpiling guns, hoarding canned food and toilet paper, and putting others at risk by defying science.

Findings from psychology help to explain these polar-opposite reactions—and how we can follow our best instincts rather than our worst ones. It all seems to come down to our terror about death. As cultural anthropologist Ernest Becker suggested in 1973, our capacity to reflect on our self poses a problem for human beings: the awareness of the existence of the self signifies that it will one day cease to exist. Within psychology, terror management theory studies how we react when death is made salient to us. In their book The Worm at the Core, Sheldon Solomon and his colleagues describe how terror management theory starts with the assumption that, like other living organisms, human beings have an instinct for self-preservation and survival. But unlike other organisms, our intellectual capacities make us painfully aware that one day we will die.

Reflecting on death is painful, but it can also help us find better ways to live. As American rabbi Joshua L. Liebman wrote in his book Peace of Mind, “Death is not the enemy of life, but its friend, for it is the knowledge that our years are limited which makes them so precious.” There’s some evidence for this claim. Among a group of patients who experienced an out-of-hospital cardiac arrest, those who came closest to a near-death experience became more tolerant of others’ differences, expressed a better understanding of themselves, appreciated nature more and reported greater meaning in their lives.

In his farewell New York Times column,the late neurologist and writer Oliver Sacks wrote that after finding out he had terminal cancer, he wasn’t finished with life. “On the contrary,” he wrote, “I feel intensely alive, and I want and hope in the time that remains to deepen my friendships, to say farewell to those I love, to write more, to travel if I have the strength, to achieve new levels of understanding and insight.”

Across a series of studies, Stanford University psychologist Laura Carstensen and her co-authors have shown that how we choose to spend our precious time depends on how much of it we perceive to have left. Once life’s fragility becomes a personal truth instead of a philosophical concept that happens to “other people,” we become more capable of celebrating whatever days and experiences remain to us instead of focusing on everyday hassles. Acknowledging our impermanence makes us more mindful of life’s small moments and our relationships with others.

Over the past two weeks, have you noticed people smiling more at one another on the street or becoming freer with their eye contact and hellos? Maybe individuals you don’t see regularly are setting up Zoom calls with you to get back in touch. Or maybe you’re carving out more meaningful routines with loved ones, from cooking together to regular video chats. In the midst of the pandemic, many of us are realizing that the clock is ticking on our opportunities and our relationships.

Humans have a history of making life’s fragility salient as a way of better appreciating the time they have. Medieval monks kept a human skull on their desk to help them reflect on their impermanence. A genre of 17th-century paintings called vanitas performed the same function—for example, by featuring a gold pocket watch ticking next to a wilting bouquet of flowers or ripening fruit sitting side by side with a human skull. Danish philosopher Søren Kierkegaard recommended allowing death to enter our consciousness to spur us toward a deeper appreciation of life and greater motivation to help fellow humans.

Some people push this awareness to its limits. Alex Honnold climbs the sheer faces of mountains, such as El Capitan in Yosemite National Park, alone—without ropes or support. “I feel like anybody could conceivably die on any given day,” he said in the documentary Free Solo. “Soloing makes it feel far more immediate and much more present.... When you’re climbing without a rope, it’s obviously much higher consequence—much, much higher level of focus.”

Getting closer to death allows many people to get unstuck from routines, and work hard on making their best contributions. It also makes some people more prosocial—that is, more willing to give to others. That effect occurs, in part, because contributing to society is one way of living on forever. Frequent reminders of death strengthen the “desire to invest one’s substance in forms of life and work that will outlive the self,” wrote John Kotre, now a professor emeritus of psychology at the University of Michigan–Dearborn, in a 1984 book.

In a series of studies entitled “The Scrooge Effect,” researcher Eva Jonas, then at Ludwig Maximilian University in Germany, and her colleagues found that people were more favorable toward charities—for instance, they thought a given charity was more beneficial to society—when they were interviewed in front of a funeral home than they were just a few blocks away. And when American participants were given a chance to donate money to an American charity, those assigned to write about their own death gave about 400 percent more than did those who instead had been asked to write about dental pain.

Interestingly, however, participants in the same study did not give higher donations to a foreign charity, because that would benefit people different from them. As this finding suggests, when death salience is high, as it is now with COVID-19, we can go either way: we might become motivated to make a positive difference, but we can also become more susceptible to the trap of racism and other forms of out-group bias.

For example, in one study Abram Rosenblatt and Jeff Greenberg, both then at the University of Arizona, had actual judges read hypothetical prosecutors’ notes for a woman charged with soliciting for acts of prostitution. Before asking the judges to set her bail, the researchers had them complete a personality questionnaire. Some of the judges received a question asking them to briefly describe their emotions when they thought of their own death. “I guess I would feel very sad for my family, who would miss me,” read a typical response.

Other judges weren’t given any death-oriented questions. They set the bond at $50—the average for that crime. Those who’d been primed to think about their own morality were much more severe: they set an average bond of $455, a staggering nine times more than the judges in the control group. When asked after the study, the judges insisted that answering questions about their death could not possibly have affected their legal decisions. After all, their job was to be rational experts who gauge cases based on facts. But the evidence suggested otherwise.

Why do humans sometimes become close-minded and moralistic when we think about our death rather than focusing on helping others? Because our morals, in-groups and nation will survive us. If we are not careful, anxiety about death can make us cling to our local culture, which allows us to “live on” in some way. So the judges who were encouraged to reflect on their death wanted to give the woman not just a slap on the wrist but the punishment she “deserved” for her moral transgression. If you let death awareness make you anxious instead of reflective, you’ll try to protect your worldview vigorously—through moralizing, nationalism, aggression against other cultures and even support for war.

This is the other side of the death-awareness coin: When our reactions move from reflection to anxiety, our behaviors become more self-protective. We fall prey to self-serving biases, and diversity efforts bother us—an effect described by University of Pennsylvania professor Adam Grant and Duke University professor Kimberly Wade-Benzoni. This is why nationalist politicians who raise the threat of war win supporters for stopping foreigners: thinking about our possible death can turn us into self-righteous, aggressive, inward-looking xenophobes.

We all have a choice about how to react to the death awareness we’re experiencing amid the pandemic. When we can manage to reflect on death without succumbing to anxiety about it, we are likely to make choices that help us make our best contributions and improve the world rather than hunkering down or lashing out.

Read more about the coronavirus outbreak from Scientific American here, and read coverage from our international network of magazines here.