Code:
on ^*:quit:{
  var %addr = ( $+ $address $+ ), %msg = ( $+ $1- $+ )

  var %i = 1, %n = $comchan($nick,0)
  while (%i <= %n) {
    if ($comchan($nick,%i) != #test) {
      echo -i2tc quit $v1 * $nick($v1,$nick).pnick %addr Quit %msg
    }
    inc %i
  }
  haltdef
}


My formatting mimics the default text, you can change it back to what you want. Note that you can use /echo -c quit to use the quit event color. This does not account for the display setting of the event (default,status,channel,hide); as I don't know of an identifier to return these, implementing this functionality would be wasted if you're not using it anyway.