The best-known example is Gilligan's Island. It was just above borderline for keeping after its third season. Tina Louise, who played Ginger, had never really liked being on the show and wanted to leave; they'd written a fourth-season premiere in which she, and only she, would get rescued. So they thought they had everything all set.
But unbeknownst to them, a CBS executive drawing up plans for the next season decided it was time, after almost 15 seasons, to cancel Gunsmoke. Unfortunately, his wife, a devout fan of the show, found out and gave him no small end of grief for that. So, he looked around and realized that the network could only justify keeping the show if it ran on Sunday nights