The episode begins with the mass suicide of the Asgard race, who try to preserve their legacy by giving their entire knowledge to the SG-1 team and the crew of the Earth ship Odyssey. When the ship is attacked by Ori warships, Lieutenant-Colonel Samantha Carter creates a time dilation field that freezes time everywhere except inside the ship, and it takes fifty years until a defense against the Ori weapons can be found.
The members of SG-1 and General Hank Landry (Beau Bridges) are travelling on the Earth ship Odyssey to the Asgard home world, Orilla, when the Asgard Thor beams aboard. He reveals that after millennia of genetic manipulation, a disease has brought his race very close to extinction, and SG-1 accepts his offer to upload the Asgard knowledge into the Odyssey as a way to preserve the Asgard legacy after the Asgard mass suicide. However, Orilla and the Odyssey are soon attacked by Ori warships. Orilla erupts with huge explosions, and as the Ori fire a final energy beam upon the Odyssey, Lieutenant-Colonel Samantha Carter (Amanda Tapping) activates a localized time dilation field that freezes time around the ship to gives the crew time to find a defense.
During the initial months on board, Vala Mal Doran (Claudia Black) repeatedly tries to seduce Daniel Jackson (Michael Shanks). Daniel finally confronts Vala for what he believes to be her insincerity, teasing, and mocking of him. Vala's upset reaction makes Daniel realize the honesty of her feelings, and they share a passionate embrace. As the years pass, each team member attempts to deal with the isolation. General Landry develops a gardening hobby; Carter learns how to play the cello; Daniel continues the translation of Asgard information in the database and develops his relationship with Vala; and Cameron Mitchell (Ben Browder) and Teal'c (Christopher Judge) exercise and train while Mitchell is growing more frustrated and angry. After many years, General Landry succumbs to old age and dies.
Carter realizes after fifty years that the power of the Ori energy beam enables the reversion of time within a localized field. However, this will mean the loss of any memories of the last fifty years. Teal'c, who as a Jaffa has a much longer lifespan than the other team members, volunteers to remain behind and perform the rescue, protected within a separate field. As the group prepares their plan, Vala and Daniel exchange a last embrace, assuring each other of their love. When everything is in place, they deactivate the time dilation field and, after the normal timeline is restored, Teal'c prevents Colonel Carter from activating the time dilation field. The Odyssey leaves before it is destroyed, saving SG-1 and the Asgard's legacy.
Back at the SGC (Stargate Command), Teal'c refuses to reveal any of the events on the ship, much to Vala's disappointment. As the episode – and the series – comes to a close, SG-1 contemplates Teal'c's joking words of wisdom in the gateroom and says "indeed" all at once, General Landry wishes the team God-speed, and SG-1 steps through the gate on their next mission.
"Unending" is the fiftieth Stargate SG-1 episode written by Robert C. Cooper, and the second episode of the series directed by Cooper. Being the series' tenth season finale, "Unending" was the fifth season finale to potentially serve as Stargate SG-1's last episode, although the writers originally anticipated another renewal of the series and planned to end the season with a cliffhanger. However, the Sci-Fi Channel announced the series' cancellation in August 2006, approximately one month before "Unending" was written. The network opposed the idea of a cliffhanger leading up to a possible movie, and since the producers never intended "to blow up the SGC and kill everyone", the episode's theme and name were chosen to give "a sense of ending without it being an ending". This move also allowed for the fan conspiracy theories surrounding a possible real Stargate under Cheyenne Mountain to continue. The option to end the series with a two-parter was considered but rejected, as Cooper felt this would have made the ending less special. The buildup of the Ori arc in Seasons 9 and 10 would eventually get a pay-off in Stargate: The Ark of Truth, a film produced after the end of the show. The cast and crew knew by the end of the episode's filming that more films would be produced.
Robert C. Cooper intended the episode as "an emotional tribute to the ten seasons that have come before" and "the last chapter in the book – but not necessarily in the series of books. It was a chance [...], using science fiction, to show people one version of what the future might be like for these characters that they've spent so much time with and loved so much." By killing off the Asgard race, Cooper gave the episode an element of tragedy that reflected his feelings at the time. Producer Brad Wright wanted all of the characters to get a last shot in the spotlight instead of focusing on only one character. Because of fan vocality about team episodes, Cooper decided to put the characters through several decades of life and see their relationships develop and evolve. The references in "Unending" to the events of season 2's "The Fifth Race", another Cooper-penned episode often named as a fan favorite, were intended, as were the callbacks to season 9's "The Ties That Bind" (the Daniel-Vala argument, see below) and season 10's "Line In The Sand" (the solution of using the Ori beam). The period aboard the ship was originally significantly less than fifty years, but the actors' last-stage makeup, which Cooper only saw minutes before filming, looked so old that Cooper was forced to increase the number of years in the script.
Cooper originally wrote the developing romance between Daniel and Vala in "Unending" by having them have sex without a confrontation. Claudia Black and Michael Shanks protested against this intended story, as Shanks felt that "[t]here's always been this underlining, keeping [Vala] at arms length because of the fear of getting too close." Cooper rewrote the scene to show Vala's vulnerability to Daniel, and have Daniel share his true feelings of a relationship. The actors decided to play the confrontation scene as genuinely as possible, with both characters being neither completely in-character nor totally out-of-character. The scene was rehearsed a lot and was filmed over the course of six hours. Cooper was nevertheless concerned that Daniel appeared too edgy and mean, although his feelings were motivated by the two years of torment with Vala, and losing his wife nearly ten years before. Daniel's line, "You better not be messing with me", was only said in one take by Michael Shanks. Since Cooper prefers to follow up on such emotional scenes with a laugh, the immediate next scene shows Vala coming out of Daniel's room, where she encounters a disbelieving Mitchell jogging by. In Cooper's mind, Daniel held a crying Vala in another scene because she had gotten pregnant and had lost the baby. To contrast the obvious relationship between Daniel and Vala, Amanda Tapping and Christopher Judge subtly played their scenes as if their characters also had a romantic relationship.
To give the Odyssey an unnatural ghostship feeling of solitude, many wide angle shots and VisFX matte extension were used with no additional music. Robert C. Cooper often listened to the CCR song "Have You Ever Seen the Rain?" during the making of the episode and decided to play it over the first montage, showing the passage of time. The tone of the second montage was set with a cello. Stargate composer Joel Goldsmith later accompanied the hand movements of the hired cellist with different music during post-production. A third montage was filmed but not included in the final cut of the episode since the last table scene already supplied the needed sentiment. Each time period included the same shots to help the audience focus on the differences that characters have gone through. The last scene at Stargate Command was the last filmed Stargate SG-1 scene, shot at two o'clock in the morning, for which every member of the crew came back.
The broadcast of "Unending" on the British channel Sky One on March 13, 2007 pulled in around 518,000 viewers, making Stargate SG-1 the third most-watched program for Sky One during that week. "Unending" attracted approximately 2.2 million viewers on its first American broadcast on the Sci Fi Channel on June 22, 2007, the best performance for SG-1 since the September 22, 2006 mid-season finale.
Reviewers were generally satisfied with the conclusion, although some like Bill Keveney of the USA Today felt the episode does not stray far from "the series formula – a mix of sci-fi adventure, relationships and humor". Jason Van Horn of IGN enjoyed the humor, "the amount of heart and pure emotion running rampant this episode", which he thought served as a symbol for the entire show that will stay in the public mind through re-runs and DVDs. Two scenes that stood out for him as "powerful", "heart-wrenching" and "the icing on the cake", were Mitchell's breakdown and Vala's seduction of Daniel signaling "the beginning of a very long lasting and loving relationship". Vala's emotional response to Daniel was interpreted as an example of her character growth, while another reviewer felt the "Vala/Daniel argument [was] a tad overwrought [although] the motivation is clear". The emotional death of Landry appealed to several reviewers, as did the resolution via Teal'c's heroic sacrifice.
The "clever, ground-breaking", "fitting" and "hugely satisfying" episode reminded hdtvuk.tv's Ian Calcutt of Star Trek: The Next Generation's finale "All Good Things", while TV Squad's Richard Keller noted strong similarities to a two-part episode of Star Trek: Voyager named "Year of Hell". He was "extremely sad to see [the series] go", but could not overlook the mediocrity, predictability and lack of originality of the series finale. TV Zone's Anthony Brown, who considered the episode "curious[ly] low-key", regretted the planned direct-to-DVD films, as "the whole thing inevitably loses its punch as the reset button's pressed [...], rather than providing the genuine emotion of an actual ending". Maureen Ryan of The Chicago Tribune thought that the episode went out on "a strange note" with a disappointing last "string of banal clichés" dialogue exchange, although the cast and the established goodwill of their characters could partly make up for it. Mary McNamara of Multichannel News lauded Cooper's direction, lighting, costuming, the "haunting" music and sound, the production values and special effects. She acknowledged the SG-1 finale as a "true ensemble/team piece" with "a poignant and satisfying conclusion", and despite not making it into the top ten of series finales, the episode was "very good" and "respects and rewards the ten year commitment viewers have made to the series".