About 170 million Americans are estimated to spend over $9 billion celebrating Halloween this year, or about $86.79 per person—almost double what we spent 10 years ago. But is the desire for free candy and the opportunity to dress up like famous cultural icons and characters the only driving force behind Halloween’s appeal? The idea of free candy and the chance to put on a different identity for a few hours are undoubtedly part of the appeal—but the essence of Halloween is to embrace the morbid, violent and macabre. So why would people choose to spend their time and resources to experience something we largely consider a toxic force in society?

This is not a new question: writers and researchers from across the disciplines have offered insight into it for centuries. Immanual Kant, for example described the experience of engaging with danger and pain from a safe distance as sublime. Little is known, however about what’s actually going on in people’s brains at the moment they’re indulging themselves in thrills and chills. So my colleague Greg Siegle and I decided to investigate this question by asking not only how people were feeling in the moment, but how their brainwave reactivity changed from before to after they did something scary.

While researchers have many ways to incite ersatz fear in laboratory subjects, they can’t really simulate the lived experience of going to a haunted attraction, complete with actors, effects, costumes, make up, and the uncertainty inherent in the “real” world. To address that gap, we had to let go of many of the standard comforts and controls found in the lab and instead collect data on the ground, from people whose only reason for showing up was to get legitimately scared.

We got permission from a localextremehaunted attraction (we’re being deliberately vague) where guests had be over 18 and had to sign a waiver informing them of the risk they were assuming before entry (but also telling them they could leave anytime. After getting approval from the University of Pittsburgh’s institutional review board as well, we set up a temporary lab in the basement of the attraction consisting of three computers; two Emotiv Epoc Bluetooth electroencephalographic (EEG) headsets; and a monitor and keyboard inside the small utility closet that served as our testing room.

Unlike the typical haunted experience with startling effects and scary characters, this one featured actors who would interact guests with in highly intense scenes: they were restrained, blindfolded, exposed to electricity and other forms of aggressive physical engagement for about 40 minutes. Due to the intensity and adult nature of the experience, we only recruited participants from guests who had already purchased tickets.

Bad weather and other unanticipated obstacles out of our control made recruitment challenging at times, however guests would often have to wait at least 20 minutes before they could enter the attraction, which worked to our advantage as we were not paying for participation.

Given the nature of the environment—we were working within a small space under time pressure with little privacy and all kinds of distracting noise—we were thrilled to find that we could in fact collect high-quality data. Over two months, we gathered pre- and post-experience survey data for a final data set of 139 women and 123 men, with a mean age of 27.5 years. Of those 262 participants, 100 completing the EEG assessment.

In addition to learning a lot about how to successfully set up, run, and break down a temporary psychophysiological lab, we gained meaningful insight, as we reported in the journal Emotion, into why people are choosing to expose themselves to what some might consider simulated torture.

First, we that learned participants felt significantly better after being scared than before, and the more scary, intense and thrilling the experience, the stronger the effect. At the same time, people who felt anxious before the attraction were significantly less so afterward. This reflects the fact, often observed in exposure therapy, that anticipation is anxiety-inducing, while resolution reduces that anxiety.

People also reported a sense of self-growth—they’d confronted their fears and learned something new about themselves, which also made them feel better. These positive gains were associated with changes in participants’ brainwave activity. Specifically, the analysis of EEG data points towards an overall decrease in activity—what some might call feeling “checked out” or “in a daze” afterwards, but in a good way.

Combined, these findings suggest that doing something scary may work towards improving mood by changing the way we process information—specifically by making us more grounded in the present moment and less inclined to get caught up in our own thoughts. Doing something scary also activates our sympathetic nervous system in the context of a personal challenge—similar to what happens when we run a 5K or engage in some other difficult physical activity. In an extreme attraction, there are also layers of uncertainty and unpredictability, and a variety of effects and characters that let guests make a conscious choice to endure, engage and overcome. Indeed, agency and choice are critical: in this attraction, guests were informed they could leave at any time.

It may seem like a paradox, but in making fear “safe,” we may make it easier to lean into the experience, and in doing so reset the bar on our tolerance for distress. Much like rough and tumble play, choosing to do something scary can be a way of practicing the experience of fear, of learning more about ourselves, or even of reminding us how strong we already are.

Whether it’s telling scary stories around a campfire or venturing into dark and forbidding woods, we’ve been scaring ourselves for centuries—and probably for much longer than that. So even if it were decreed that Halloween would be stripped from now on of candy and costumes, we’ll likely still be finding ways to scare ourselves.

Although to be honest, chocolate really does taste better after a good scare.