It’s a little surprising it took Agents of S.H.I.E.L.D. this long to find its groove. After all, it was created by Joss Whedon: a TV veteran who brought comic-book storytelling to the small screen with Buffy the Vampire Slayer and who was once a creative mastermind behind the Marvel movies. But Agents didn’t pick up until the April 2014 release of Captain America: The Winter Soldier, which revealed that S.H.I.E.L.D. had been infiltrated by supervillains and was rotten to the core. Before that, the stodgy cast had been obeying the orders of an unseen bureaucracy; with that bureaucracy removed, they could burrow into larger, wackier mysteries about alien experimentation, Nazi mysticism, and portals to other worlds.

In the second-season finale, the plucky scientist Jemma Simmons (Elizabeth Henstridge) got sucked into said portal, and was only recovered months later. “4,722 Hours” chronicled her journey on the alien world she got stuck on, audaciously never cutting back to the present day or to her Earth-bound colleagues. The episode even had Henstridge’s name come first in the cast order, a rare TV phenomenon (she’s usually sixth-billed). “4,722” bore a superficial (and likely unintentional) similarity to The Martian, but with a more foreboding atmosphere: Simmons was trapped on a planet where the sun seemingly never rose, beset by hallucinatory dust storms, and her only companion was a long-stranded astronaut that NASA had sent through the same portal years before and left to die.

There aren’t many TV shows that could pull an episode like this off. Even the obvious forebears, like the various Star Trek series, would have done so as cheaply as possible, finding some abandoned quarry or quiet forest to shoot in. Simmons’s planet, which was mostly a desert, still felt appreciably alien thanks to moody lighting and foreboding blue camera filters. Her trial to get back home, which viewers knew would end in success, still felt hard-earned, and should powerfully inform her character and the way her team tries to adjust to her presence again.

Aside from the terrific “4,722 Hours,” this season has been building up in other interesting ways. S.H.I.E.L.D.’s first season took place mostly on an airplane, a roving base for the team that could take them to any location in the world but ended up serving as the dull setting for 80 percent of every episode’s action. Now, the show’s expanded cast is scattered across the globe, chasing story threads that occasionally knit together before expanding out again. Fortunately, Agents is laying the foundation for its own stories rather than serving as a larger cog in the Marvel universe. Simmons didn’t visit an alien planet to introduce viewers to a location Thor might visit one day; her tribulations simply existed to deepen her character and tease at some other mysteries.