Peter Capaldi is saying farewell to Doctor Who this Christmas when the Doctor regenerates into Jodie Whittaker, but Steven Moffat may have helped soften the blow.

That's because the showrunner and writer, who is also leaving Doctor Who after Christmas Special 'Twice Upon A Time', let Capaldi play a part in the writing of his own regeneration scene.

"The truth about writing anything is that it's always difficult. You can change the reason why it's difficult, but the fact is it's just always difficult!" Moffat said.

BBC/BBC Worldwide

"Throughout writing this I wanted to feel more about the fact it's the last one I'll ever write, and I wanted to feel more about it's the last one Peter will ever play, but the truth is that the technicality and the difficulty and the demands on your creativity - all that overwhelms you to the point where you're just trying to write a great Doctor Who story!

"That's enough to contend with – you can't have the real life drama of two old Scotsmen making their way to the door."

He continued: "Once we got into shooting it, however, and especially when we approached filming Peter's last moments as the Doctor, which were done at the end of the shoot, we did talk more about how exactly he should meet his end.

"We were both very pleased with that final section of the script already, but as we went through piece by piece we thought there were ways to improve it so I'd be banging out new pages each night for us to discuss on set each day.

"That was so enjoyable and exciting to do – to really feel that we were getting his send off right – that in a way it took whatever emotions we were both having about leaving and put them on screen where they belong.

"By the time we got to that part of filming I think Peter and I were probably the least emotional on set because we'd put it all in the show!"

In a goodbye note to the character, Capaldi said: "Doctor Who has taken me on an amazing journey. I went to the end of time. I met fantastical creatures. And I blew them up.

"Now that it's coming to an end, I wish the Doctor all the very best for the future, and the past, and everything in-between. Time I was off."

Moffat had previously hinted that Capaldi's regeneration could be the most explosive ever seen on Doctor Who.

"I was worrying about this with Chris [Chibnall, taking over as showrunner in 2018]. Every time we regenerate him, he's blowing up more and more shit, isn't he?" Moffat told Digital Spy.

"He used to lie delicately on the floor and wibble a bit, and he'd be somebody else. Then [in David Tennant's swansong, 'The End of Time'], he blows up the whole entire TARDIS – for no reason that either Russell [T Davies] or I could think of, but someone on the internet suggested that it was because of all the radiation he'd absorbed."

He continued: "Then [in Matt Smith's final outing, 'The Time of the Doctor'], he blows up an entire Dalek fleet.

"I mean, he must be worried he's going to wipe out half the universe this time. So we have included the idea that it's getting more volcanic each time."

Doctor Who: Twice Upon a Time airs on BBC One on Christmas Day at 5.30pm

Want up-to-the-minute entertainment news and features? Just hit 'Like' on our Digital Spy Facebook page and 'Follow' on our @digitalspy Twitter account and you're all set.

This content is created and maintained by a third party, and imported onto this page to help users provide their email addresses. You may be able to find more information about this and similar content at piano.io