I think season five was the first season where Miles and Gough stated that they had written a finale for the show, but then got the green light from the network. There was IIRC at least two finales written that they admitted to. Season Five. Season Seven (the writers strike affected season). Brian and Kelly stated in an interview that some of what Miles and Gough intended for their series finale ended up in their script.