“The Big Bang Theory” wraps its 12-season run with Thursday night’s one-hour finale (8-9 p.m. on CBS).

TV’s top-rated ensemble comedy about a band of brilliant misfits has kept viewers laughing since 2007 with stars Jim Parsons (Sheldon), Johnny Galecki (Leonard), Kaley Cuoco (Penny), Simon Helberg (Howard), Kunal Nayyar (Rajesh), Mayim Bialik (Amy) and Melissa Rauch (Bernadette).

It also attracted many A-list guest stars, including celebs featured in these episodes:

Stan Lee: “The Excelsior Acquisition”

The comic book icon briefly appeared in an episode where Penny (Cuoco) and Sheldon ring his front doorbell after missing him at an autograph signing. An obviously annoyed Lee, dressed in a Fantastic Four bathrobe, isn’t having any of it.

“You know, you fan boys are unbelievable,” he says. “Why don’t you just come in and watch the Lakers game with me?” Sheldon seizes the opportunity.

George Takei and Katee Sackhoff: “The Hot Troll Deviation”

Takei (“Star Trek”) and Sackhoff (“Battlestar Galactica”) appear in Howard’s (Simon Helberg) subconscious in a fantasy sequence.

William Shatner: “The D&D Vortex”

Shatner plays himself during the production of Professor Proton’s science show featuring Sheldon (Parsons) and Amy (Bialik). While on set, there’s a knock at the door and Shatner joins them. Sheldon exclaims, “Captain on the bridge! Captain on the bridge!” When Shatner agrees to call Sheldon “Science Officer Cooper” he gets so excited that he vomits all over the “Star Trek” icon.

Carrie Fisher: “The Convention Conundrum”

In this episode, the gang tries and fails to attend Comic Con. Disappointed, Sheldon tries to set up his own version of the geek convention, which leads to hanging out with James Earl Jones. Fisher plays herself as they prank her by knocking on her door and running away.

Stephen Hawking: “The Hawking Excitation”

The legendary physics and cosmology genius appears in Season 5, reading Sheldon’s theory that Boston is the center of a black hole accelerating through time — and commenting that it’s fascinating but incorrect because of a math error. When Sheldon faints, Hawking says, “Great, another fainter.”

Bill Nye: (two episodes)

The host of “Bill Nye the Science Guy” appeared in Season 7’s “The Proton Displacement” and in Season 12’s “The Conjugal Configuration” when he’s befriended by Sheldon.

Mark Hamill: “The Bow Tie Asymmetry”

The “Star Wars” legend plays himself in this episode where he officiates at Sheldon and Amy’s wedding as a favor to Howard, who found his dog, Bark Hamill.