The Shootist
(1976)

John Bernard Books (John Wayne) is an aging, legendary gunfighter (a shootist).  Books has been feeling poorly and comes to town to be examined by Doc Hostetler (James Stewart), who had previously saved Books' life after a shootout.  The Doc diagnoses him with cancer and gives him just a short time to live. 

Books moves into a boarding house run by the widow Rogers (Lauren Bacall). Her son, Gillom (Ron Howard), is in awe of the old gunfighter.  The other boarders move out rather than stay in the same house with such a notorious person.  Mrs. Rogers tells him to move out but when he confesses his illness, being a good Christian woman she allows him to stay.  He eventually forms a bond with both Mrs. Rogers and Gillom (whom Books gives a shooting lesson).

Over the course of the movie, Books encounters a series of characters as he waits out his time and puts his affairs in order.  A newspaper editor who wants to write his story as a dime novel, an old flame, the town sheriff who just wants him to die, the town bully, a crack-shot faro dealer (Hugh O'Brien), and an old nemesis Mike Sweeney (Richard Boone).

During a follow up visit with Doc Hostetler, the Doc describes how the disease will progress and offers that Books must be a brave man and a brave man should not suffer such a fate. 

On his birthday, Books arranges to meet the bully, the faro dealer and Mike Sweeney early one morning at a saloon.  In the ensuing gunfight, Books kills the three men but a bartender shoots Books from behind with a shotgun.  While the bartender reloads to finish Books off, Gillom runs in, grabs Books' six shooter and kills the bartender.  He is disgusted by the act, though, and throws the gun away.  A mortally wounded Books nods approvingly and dies.  Gillom then walks out of the saloon as people gather outside to see what has happened.

Thanks TZF1JN!