Most people look forward to retirement, a reward for decades of hard work. But like many other pleasures, it may be bad for your health. It may even kill you.

How can that be? How can working longer be good for your health? After all, many people dream of—and plan for—retiring early. Strenuous, stressful work can wear people down and damage their health. On the other hand, retirees can relax and reinvigorate themselves. They have time to follow their passions and pursue activities that enrich their lives.

But in our rush to leave the office, we don’t realize that retirement also has a downside, especially over the long term. Many retirees indulge in unhealthy behaviors. They become sedentary and watch too much television. They eat too much. They drink too much. They smoke too much. Without the purpose of fulfilling work, retirees can feel adrift and become depressed. Without the camaraderie of their co-workers, retirees risk becoming socially isolated. Without the intellectual stimulation that work can provide, retirement can accelerate cognitive decline.

The problem for researchers is measuring which is the more powerful force—the joys of a more leisurely life or the downsides. An experimental study, in which researchers randomly force some workers to retire and others to remain in the labor force, would provide the best evidence, but that kind of experiment is impossible.

Instead, researchers have turned to statistical models that rely on factors that affect work but are unrelated to health—like Social Security eligibility ages, tax breaks for older workers or mandatory retirement rules. Researchers then can determine how health changes when these milestones are reached.