With “The Rise of Skywalker,” set to open Dec. 20, composer John Williams closes the book on his 42-year history with “Star Wars” after nine films and more than 20 hours of some of the most lavish and memorable symphonic accompaniment in the history of movies.

“Forty years ago, if you said to me, ‘Here’s a project, John, and I want you to write 25 hours of music,’ I would have dropped my pencil case and said, ‘It’s impossible. No one can do that,’” the composer says with a laugh.

Yet he has, and for “The Rise of Skywalker,” he penned more than three hours of music, though the film itself only runs two and a half hours: New or revised music was needed throughout the recording process, which took 11 days between mid-July and late November.

“As with ‘The Force Awakens,’ things were [changing] considerably during postproduction,” director J.J. Abrams explains, “and I would always apologize that we were making adjustments, and John would always laugh and apologize that he hadn’t written the right thing before. We were both just full of apologies to each other.”

Despite the workload, which occupied much of his year, the 87-year-old composer insists, “It was a wonderful way to spend six or eight months. Each day I got up to work hard on difficult music. Yes, it was long, but I always had a sense of being grateful — having the energy and interest to do it and to work with the orchestra, which was especially lovely.”

“The Rise of Skywalker” was, like the previous two “Star Wars” films, recorded in Los Angeles. He praises the orchestra as “the equal of almost any, surpassed by very few.” Augmenting his 102-piece ensemble was the 100-voice Los Angeles Master Chorale, which got to sing a few syllables in the ominous Sith language, Williams confirms.

“It was exciting,” says one musician who played on the sessions. “Everyone was giving 110 percent. We were all honored and grateful to be there. John orchestrates everything, he conducts his own music and he’s so aware and in control. How does he have the energy to do all that?”

In the interests of secrecy, no film was projected while Williams was conducting the orchestra (which is routine on most film dates). Williams, Abrams and music editor Ramiro Belgardt watched playbacks on small video screens out of sight of the players.

The famous “Star Wars” themes — including the opening fanfare, music for the Force and themes for Rey and the Emperor — return, along with four new motifs: the darkly hued “Anthem of Evil,” an optimistic “Rise of Skywalker” theme, a scherzo for action sequences and new music for Kylo Ren (Adam Driver). Williams also makes a cameo appearance in the film.

Abrams was respectful of the five-time Oscar winner. “In certain instances, I would suggest a feeling, but I would never deign to suggest what he should write,” says the director. “That’s the reason he is who he is, not because anyone’s told him what to do.

“He watches the cuts, goes to his piano, writes his music, then goes to the recording sessions, and only John has really heard it in his head. All of a sudden, with a stroke of his baton, these masterful musicians are playing something that sounds like they’ve been rehearsing it forever. It’s the most miraculous part of the process.” 

Williams credits longtime filmmaking partner Steven Spielberg for introducing him to “Star Wars” creator George Lucas in 1976. “I went up to George’s ranch and looked at it,” the composer recalls. “I felt like I was looking at a world none of us had ever seen.”

Lucas asked for a “classical” score, Williams adds, “with a big sweeping orchestra, something very theatrical and operatic.” The composer’s response: “That’s wonderful. It’s not my style, but I’ll do the best I can. It’ll be fun.”

That style — “tonal and melodic and thematic, where characters could be identified musically with fun, luxurious orchestration,” in the composer’s words — became the backdrop of the entire “Star Wars” universe. At the suggestion of 20th Century Fox music director Lionel Newman, they recorded the initial score (and five subsequent “Star Wars” scores) with the London Symphony Orchestra.

Many of those themes have become iconic, notably “The Imperial March,” better known as Darth Vader’s theme. Later pieces, from the love theme in the prequels (“Across the Stars”) to the thrilling choral piece “Duel of the Fates,” demonstrate Williams’ seemingly endless ability to conjure the right emotion for every scene. He won an Oscar for the first film and received four more Oscar nominations and multiple Grammys for the others.

Actors Mark Hamill (Luke Skywalker), Daisy Ridley (Ren) and Kelly Marie Tran (Rose) dropped by the sessions and, on the final day of recording, several luminaries also visited: Spielberg, Lucasfilm president Kathleen Kennedy, Disney chairman and CEO Bob Iger. Speeches, champagne toasts, and a giant cake (in the form of droid BB-8) followed.

“The day was loaded with emotion,” says another musician who performed on that last session. “People were aware of the significance of the day, and how historic it was.” Said another: “There were so many people crying, you couldn’t believe it. And at the end, the orchestra gave John an ovation that would not stop.”

Reminded that this four-decade sojourn “in a galaxy far, far away” concluded with a massive ninth effort, almost like a series of symphonies, Williams laughed and said it hadn’t occurred to him. “Any comparison with Beethoven would be sacrilegious,” he says, “but I like the idea of completing a cycle at number nine. It will keep me quiet for a while.”

Mike Matessino, producer and essayist on numerous expanded and reissued soundtrack albums, puts it this way: “There is simply no frame of reference for what John Williams has accomplished with the ‘Star Wars’ saga. It has never happened before and will never happen again. ‘Star Wars’ is like all of musical storytelling history focused to a single point. You feel it when you hear the music and experience the stories, and you know it will never get old.”

Says Abrams: “It’s probably impossible to describe the impact that he has had on those movies. John created import and terror and heroism and bravery and a sense of adventure and romance. Had anyone else tried to do what he did, I don’t know if we would be talking about ‘Star Wars’ today. John Williams is as responsible for what ‘Star Wars’ is and has always been, as anyone.”