The cast of The Big Bang Theory have taken part in a flash mob on set as they prepare to wrap up filming on the long-running sitcom.

Kaley Cuoco, who has played the character of Penny since the show’s inception in 2007, shared footage of the stunt on Instagram.

The actress, 33, said the dance “might be one of my favourite moments in 12 years”, adding: “I told you we would go out with a bang!!”

Cuoco’s co-stars including Jim Parsons, Mayim Bialik, Melissa Rauch, Kunal Nayyar and Simon Helberg all joined in with the dance, set to the Backstreet Boys’ Larger Than Life, while the studio audience clapped along.

Johnny Galecki, who plays Leonard Hofstadter, sat out after suffering an ankle injury.

The cast and crew spent months rehearsing the dance, according to Cuoco, who said “it was worth it”.

It is not the first time the cast of The Big Bang Theory has taken part in on-set flash mobs, having previously danced along to hits including Bruno Mars’ Uptown Funk and Call Me Maybe by Carly Rae Jepsen.

However, this dance had an added poignancy, considering the cast will soon wrap up filming for good.

The final episode is due to air in May. The Big Bang Theory centres on a group of scientists and their relationships.

The programme will end in after 279 episodes, and will be the longest-running multi-camera series in television history.

Following the announcement in August that The Big Bang Theory would end, Cuoco said she was “drowning in tears”.