The decision to write Meghan Markle out of her TV show Suits was made in the early days of her relationship with Prince Harry.
The programme's creator Aaron Korsh admitted he took a gamble that her then-burgeoning romance with the royal was going to work out.
The couple started dating in July 2016 after being set up on a blind date by a mutual friend. They dated in secret for months before it became public knowledge that autumn.
Following months of rumours, it was finally confirmed this week the actress was quitting her role as Rachel Zane to start a new life in Britain with her fiance.
Korsh told BBC Radio 4's Today Show: "I knew from a year ago that this relationship was burgeoning and I had a decision to make because I didn't want to intrude and ask her, 'Hey what's going on and what are you going to do?'
"So collectively with the writers, we decided to take a gamble that these two people were in love and it was going to work out."
He continued: "What we decided to do (was to) say, 'Look, I would rather have good things happen to Meghan in her life,' - which would likely mean her leaving the show.
"So let's plan on that and it's much easier to undo that, if it came to it, than to just plan on her staying forever and then finding out she's going to go.
"And the only way to write a character out like that would be if they got hit by a bus or something."
Meghan's character Rachel is due to tie the knot with her on-screen boyfriend Mike Ross, played by Patrick J Adams, who is also leaving the show.
Following Meghan and Harry's engagement announcement, it was revealed the Californian-born star would be quitting acting altogether, becoming a UK citizen and would be baptised ahead of her new role as a British royal.