James Stewart was at the height of his Hollywood career when he left acting for military service. His determination to fly combat missions, despite concerns about putting a famous actor in danger, is the subject of “Jimmy,” a new film opening in theaters Nov. 6. K.J. Apa plays Stewart, with Max Casella portraying director Frank Capra.

Stewart won an Academy Award for “The Philadelphia Story” in 1941, the year that began an absence from movie screens lasting almost five years. Already an experienced pilot, he enlisted in the Army Air Corps. Although he could have remained in the United States making recruiting films, he sought a more active role in the war.

Janie McKirgan, curator of the Jimmy Stewart Museum in his hometown of Indiana, Pennsylvania, said Stewart understood that the country needed skilled pilots. His celebrity, however, complicated his efforts to fly. Military officials worried that losing an Academy Award-winning star would damage morale among troops and the American public, and he struggled to find someone willing to accept that risk.

Stewart ultimately flew 20 combat missions over Germany, losing men and witnessing events he seldom discussed afterward. His daughter Kelly Stewart Harcourt, an executive producer of “Jimmy,” said he never spoke to his children about his wartime service. She recalled that he returned uncertain about his future, questioning whether he wanted to resume making films.

After Stewart died in 1997, Harcourt and her twin sister discovered a diary in his nightstand. Sharing passages she had not previously made public, Harcourt read an account of a mission in which his group lost 13 crews and only half returned. Another entry described the relief when everyone came back safely the following day, alongside Stewart’s distress at how quickly that relief could overshadow the earlier losses.

Harcourt said her father experienced nightmares, depression and anxiety, symptoms she described as consistent with what would now be diagnosed as PTSD. She believes those experiences informed his portrayal of George Bailey in Capra’s “It’s a Wonderful Life,” his first film after the long Hollywood absence. The connection between his wartime suffering and the performance has been the subject of speculation, though it cannot be established with certainty.

For the actors in “Jimmy,” Stewart’s military history was unfamiliar territory. Casella said he had known only vaguely about it, while Apa said he had not known the story and was struck by Stewart’s courage. Apa described their aim as making the film that Stewart and Capra never had the opportunity to make.

Stewart appeared in more than 50 additional films after “It’s a Wonderful Life,” but regarded his service to his country as his greatest source of pride. At his Kennedy Center recognition in 1983, an appearance by cadets from the U.S. Air Force Academy brought him close to tears.