Happy Valley creator Sally Wainwright said Catherine Cawood star Sarah Lancashire was not happy with the original script she gave her.
Sally, who created and wrote the gritty BBC crime drama, joined Newsnight on Monday night to discuss the show, the ending, and a possible spin-off with Ryan.
Sally said she was worried the ending might "fall at the final hurdle", but that she took a lot of input from Sarah Lancashire after the first draft, Yorkshire Live reports.
READ MORE: Happy Valley fans 'work out' what happened after credits rolled
She said: "I think because it appeared to be doing very well I was worried it might fall at the final hurdle and people might think it was a disappointing ending in some way but I kind of knew it wasn't. I knew it was what I wanted it to be.
"It was satisfying. I had a real choice about whether to end on a pessimistic note or an optimistic one."
Sally said ending the series with a "force for good" was a "no brainer", before adding: "I have Sarah to thank for that ending in many ways. I wrote the first draft and everyone seemed happy with it and she made it clear she wasn't happy with it.
"It was a great privilege to have the opinion of someone who knew the scripts almost better than I do... she was literally here all day at my house talking it through. Her performance is just off the scale."
Sally was then asked if that's "definitely it" for Happy Valley?, to which she replied: "Yes that's definitely it. We made it clear we didn't want it to go on and on and become a pale shadow of itself.
"Just to know when to stop. I think it's good to know when to stop in all walks of life."
Receive newsletters with the biggest and breaking TV and showbiz news by signing up here
READ NEXT:
Amanda Holden strips down to underwear as BGT auditions get underway following David Walliams exit
Turkey travel warning as Foreign Office releases new guidance for UK visitors
Iceland fans 'clearing freezers' over 'unreal' new snack
I tried a £40 Aldi SpecialBuy and it's honestly worth three times the money
Bride has 'no regrets' after having wedding without the groom