How to fix MissingReferenceException when a GameObject gets destroyed from an array?

Got this code from a free turret asset. I’ve got 5 turrets set as enemies, my problem is every time one turret or all turrets get destroyed it throws this MissingReferenceException warning on the console.
Any idea on how to fix this, thanks in advance.

  public GameObject[] turrets;
    
        public virtual void Update(){
            foreach(GameObject turret in (this.turrets as GameObject[]))
                turret.SendMessage("Target", this.transform.position);

    }

Try checking that it still exists before sending the message. Something like this.

public virtual void Update()
{
    foreach(GameObject turret in (this.turrets as GameObject[]))
    if(turret != null)    
        turret.SendMessage("Target", this.transform.position);
}