If superhero cinema, in all its brand-focused, cineplex-dominating, sequel-heavy glory, is the definitive genre of Hollywood’s last decade, then surely Hugh Jackman’s Wolverine is its biggest icon. The surly, muscle-bound, metal-clawed hero has appeared in countless X-Men films and spinoffs since his debut in 2000; in that time, the comic-book movie has evolved from genre sideshow to a chief pillar of many a film studio’s economy. It might sound trite to call Jackman’s work as Wolverine seminal, but it’s certainly hard to imagine anyone else in the role—a fact that gives Logan, supposedly a sendoff for the character, real oomph.

It also helps that director James Mangold, who also directed Jackman in the previous Wolverine film (2013’s simply titled The Wolverine), secured an R-rating for Logan’s last hosanna, and he makes the most of it. This is a grimly violent movie, filled with vicious stabbings, frequent profanity, and a general sense of fatalism. It’s also quite good, selling itself as a Peckinpah-inspired Western about an old gunslinger riding out on one more doomed quest for glory. It would have been easy for Logan to retread the character’s greatest hits in another epic superhero battle, or to delight in the newly available levels of gore. It opts for something different, and it largely works, giving Jackman a worthy final chapter to hang his claws on.

The dirty little secret few critics dare mention is that Mangold’s last film, The Wolverine, was just as good as Logan, if not better. It somehow married a Fellini-esque journey through the hero’s tortured psyche with a samurai film, keeping its action intimate and character-oriented, and layering in an ensemble of female characters who actually had their own agency. But The Wolverine does undoubtedly go off the rails a little in its third act, which relied more on traditional big-budget superhero nonsense and a CGI monster. Mangold has learned his lesson on that front—Logan is mean, lean, and always keeps its camera close to the ground.

The film is set vaguely in the future, some years after super-powered mutants began to die out (including all of Logan’s pals in the X-Men). Mangold and his co-writers Scott Frank and Michael Green take pains to avoid placing the story in any timeline too specific. This is a possible future, nothing more, making Logan an X-Men story that doesn’t have to worry about what the other 15 cast members of the last movie are up to right now. Logan lives in the Arizona desert with his shifty pal Caliban (Stephen Merchant), a sardonic, chalk-skinned mutant who helps him tend to Charles Xavier (Patrick Stewart, also giving a swan-song performance), the former leader of the X-Men, who’s slowly losing his mind.

Logan (he seems to have abandoned the Wolverine moniker for the most part) has also seen better days. The opening scene of the film sees him brutally fight off a gang of carjackers, but while his metal claws still work just fine, his healing powers are much diminished, now supplemented with handfuls of pain pills and healthy gulps of liquor. His final goal is to buy a boat and live out on the ocean with Xavier, but when a little girl named Laura (Dafne Keen) shows up on his doorstep, having escaped from some secret facility and sporting her own metal claws, that plan swiftly goes out the window.

If this is a Western, Logan is very reminiscent of broken-down antiheroes like Clint Eastwood’s William Munny in Unforgiven—a trained killer nursing decades of regret and sorrow, with enough juice for one last mission. Mangold proudly wears his influences on his sleeve; a pivotal scene sees Xavier and Laura watching a clip from George Stevens’s seminal 1953 film Shane, about another grim gunfighter with a mysterious past. Logan prefers hand-to-hand combat, of course, but aside from that he’s quite similar to Alan Ladd’s character in that film, a trained killer who fought for the good guys but didn’t consider himself one of them.

Mangold is an excellent director with a solid, unheralded resume (including the Johnny Cash biopic Walk the Line and the Sylvester Stallone neo-noir Cop Land). But Jackman and Stewart are, quite simply, why Logan works—they’re why the film doesn’t just feel like a cheap exercise in bloody violence, and why its subversion of typical superhero-movie tropes feels organic (unlike with the X-Men spinoff Deadpool). The actors bring warmth and grouchy humor to the story, barking at each other like the married couple they’ve become, as they go on a road trip north with their young ward in tow.

The story itself is a little all over the place—Logan and company ping-pong from location to location across the country, as the villainous Donald Pierce (Boyd Holbrook), a metal-armed bounty hunter, chases them in search of Laura. A long digression at the house of a friendly family of civilians feels a little forced; the film’s bloody climax, involving a sniveling scientist (played to the hilt by Richard E. Grant) and another mysterious enemy, slightly overstays its welcome. No matter—anytime things get too out of hand, Jackman and Stewart are there to tether them back to earth, and at no point does a cosmic portal appear in the sky, or a giant purple supervillain start a monologue about magical gems.

If this is Jackman’s final run at the role (comic-book characters do have a way of making surprise comebacks, so I’m wary), it’s a peculiar milestone worth noting—he’s our first superhero actor to officially age out of a role, a testament to the extreme longevity of some of these franchises. Will we get another Logan one day? Quite likely, no matter how foolish a proposition that might be; this is a world with a new Han Solo and a new John McClane, after all. All the more reason to salute Jackman as he rides out into the sunset; that’s Logan’s chief task, and it succeeds splendidly.