With the publication of “Gwendy’s Final Task,” one of the more memorable collaborative enterprises of recent years comes to an end. The Gwendy saga began in 2017 with “Gwendy’s Button Box,” a tightly constructed short novel co-written by Stephen King and Cemetery Dance publisher Richard Chizmar. In 2019, Chizmar carried the story forward with “Gwendy’s Magic Feather,” a solo effort that effectively maintained the tone and overall ambiance of its predecessor. For this final volume, the prolific King has rejoined the narrative, and the result is the longest, strangest, most satisfying installment in the trilogy.

“Gwendy’s Final Task” contains enough backstory and explanatory detail to stand on its own, but familiarity with the earlier volumes is recommended. Together, the three books constitute a single long narrative encompassing the life and times of its eponymous hero, Gwendy Peterson, an ordinary young woman handed an extraordinary — and inescapable — responsibility: preserving the universe.

The story begins in 1974 in Castle Rock, Maine — ground zero of the Stephen King fictional universe — and ends, more than 50 years later, in outer space. The precipitating event is an encounter between Gwendy, then a determined, slightly overweight 12-year-old, and an enigmatic stranger named Richard Farris, who may not be entirely human. Farris tells Gwendy that she has been chosen as temporary caretaker of a mysterious and potent object called the Button Box, which possesses powers both destructive and benign. The box will come into Gwendy’s possession on three separate occasions, and her stewardship of it will define — and alter — the entire course of her life.

The box itself is a mahogany artifact with levers at each end and eight color-coded buttons across the top. The levers dispense treats: exquisite animal-shaped chocolates and vintage silver dollars minted in 1891. The colored buttons have a darker function. Each is associated with a specific continent, and depressing any of these buttons will literally destroy its corresponding continent. A black button — what Gwendy comes to think of as the Cancer Button — will destroy everything. The Box, in effect, is a Doomsday Machine whose nature and origin are unresolvable mysteries. It is also a burden, one that Gwendy will carry for many years to come.

The first two volumes take us through the first few decades of Gwendy’s life, from awkward adolescence through an increasingly accomplished adulthood that includes successful careers in literature and politics. At the same time, her periodic stewardship of the Button Box brings its own share of stresses and responsibilities. As the final volume opens, the world has changed — and darkened — considerably, and Gwendy’s role as guardian has changed as well.

“Gwendy’s Final Task” begins in 2026. The coronavirus still exists, and cautious older people still wear masks. International threats and internal political divisions have deepened. The Button Box itself has grown increasingly unpredictable, as though reflecting the instability of the outside world. Gwendy, now 64, is a Democratic senator from Maine, and she carries a pair of enormous secrets. The first is the existence of the box, which has reentered her life for a final time. The second is the fact that, possibly because of long-term exposure to the box, she is in the initial stages of Alzheimer’s disease.

Complicating matters further is a new and unforeseen factor. Powerful, inhuman forces have focused their attention on the Button Box — and on the black button that threatens the existence of all living things. As the forces of chaos and discord reveal themselves, it becomes clear that the Gwendy saga is part of a larger, overarching fictional universe: the world of King’s Dark Tower. The forces attempting to acquire the box are the same ones attempting to bring down the Tower, which holds together an infinite number of possible worlds. Their continued existence depends on Gwendy and on the successful completion of her final task.

The task now is to rid the world — all worlds — of the box she has spent her life protecting. To do so, she must travel to the only place where the box can be safely disposed of: outer space. In a carefully prepared scenario, Gwendy travels to a newly constructed international space station, at which point her own destiny and the destiny of the Button Box converge. Combating an array of opposing forces — chief among them her declining mental faculties — she struggles to complete the task assigned her more than 50 years before. The final pages are both satisfying and unexpectedly moving. Like its predecessors, “Gwendy’s Final Task” is both a seamless act of collaboration and a deeply felt reflection on the perilous state of our fractured modern world.

Bill Sheehan is the author of “At the Foot of the Story Tree: An Inquiry into the fiction of Peter Straub.”

Gwendy’s Final Task

By Stephen King and Richard Chizmar

Cemetery Dance. 408 pp. $28