The switch you need to close a query window is -m

Code:

on *:OPEN:?: {
  if ($query(0) < %query) {
    .notice $Nick ya esta bloqueado el privado $query(0)
    close -m $nick
    halt
  }
}