You are washing dishes or driving to work when a song you have not heard in weeks starts playing in your head, and it will not leave. You did not choose it. You may not even like it. Yet the same four bars keep looping while the rest of the song stays out of reach. Almost everyone has lived through this, and researchers have a name for it. They call it an earworm, or more formally involuntary musical imagery, and it turns out to be one of the more studied quirks of the human mind. Understanding what is happening explains both why it feels so sticky and why it eventually fades.

An earworm is a small piece of music that repeats in your mind without your permission. Surveys suggest that the vast majority of people experience them, often several times a week, and that they usually involve a short chunk of a song rather than the whole thing. That looping fragment is almost always the catchiest part, the hook or the chorus, the section built to be memorable in the first place. The tunes that get stuck tend to share certain traits. They often have a simple, repetitive melody, an easy rhythm, and a small surprise, like an unexpected jump between notes, that keeps the brain paying attention. Songs designed by professionals to lodge in your memory are, unsurprisingly, very good at lodging in your memory.

The deeper reason has to do with how memory works. Your brain does not store a song as one solid block. It stores it as a sequence, where each note or phrase points to the next one. When something triggers the opening of that sequence, your mind starts running the pattern forward almost automatically. The trouble comes when the loop hits a point where the memory is incomplete or the ending is fuzzy. Instead of resolving, the sequence snaps back to the start and plays again. Psychologists sometimes describe this as the brain trying to finish an unfinished task, the same pull that makes an interrupted story or an open question nag at you until it is closed.

Triggers are everywhere, which is why earworms feel so random. Hearing even a second of a song can set one off, but so can words, places, moods, and people that your brain has quietly linked to that music. Stress and tiredness make earworms more likely, because a tired mind wanders more and has a harder time steering itself. Boredom does the same thing, which is why they strike during repetitive chores or long commutes when your attention has nowhere else to go. Recent exposure matters too, so the song playing everywhere this month is far more likely to haunt you than one you have not heard in years. The pattern is not truly random, it just draws on associations you are not aware of.

So how do you get rid of one? The research points to a few approaches that actually help, and they are more interesting than simply telling yourself to stop. One is to let the song finish, either by playing it all the way through or by mentally running it to its real ending, which can close the loop your brain keeps reopening. Another is to give your mind a different task that is engaging but not overwhelming, since an empty or bored mind invites the loop back. Some studies have found that chewing gum reduces earworms, likely because the jaw movement interferes with the part of the brain that rehearses sound. Curiously, trying hard to suppress the song often backfires and makes it stronger, the same way telling yourself not to think about something guarantees you will.

There is also a well known trick that many people swear by, sometimes called a cure tune. The idea is to deliberately play or hum a different song that is catchy enough to take over but not so catchy that it becomes the next earworm. Certain songs come up again and again in these accounts as reliable replacements, though the exact choice varies from person to person. It is not a guaranteed fix, and for some people it simply swaps one loop for another. Still, the underlying principle is sound, since the goal is to occupy the same mental space the earworm was using. Redirecting the brain tends to work better than fighting it head on.

For almost everyone, earworms are harmless and even a little enjoyable, a sign of a mind that loves pattern and music. They usually last a few minutes to a few hours and fade on their own once your attention moves fully to something else. In rare cases they can become persistent and intrusive, and when that happens it is worth mentioning to a doctor, but that is far from the norm. The next time a chorus takes up residence in your head, you can at least appreciate what it reveals. Your brain is a relentless pattern machine, wired to remember, predict, and complete, and a stuck song is just that machinery caught in a small and catchy loop.