Tom Baker and Elisabeth Sladen wrote Sarah's departure themselves. In the script, it was deliberately left blank.
After Sarah Jane is released from Eldrad's influence, she says "ELDRAD MUST LIVE! - Just testing". This was a prank by Elisabeth Sladen on Tom Baker, but it seemed so in-character that the director kept it in.
In the final scene, Sarah Jane whistles the tune, "Daddy Wouldn't Buy Me a Bow-Wow". Since Elisabeth Sladen was unable to whistle, director Lennie Mayne provided the whistling while she mimed to it.
After Elisabeth Sladen's departure, Tom Baker became ill-tempered and withdrawn. Her successor Louise Jameson felt that she wasn't treated well by him. After she confronted him about it, not only did their working relationship improve, they also became good friends.
This episode was watched by 12 million viewers on its original transmission.