from the help file.
$query(0) returns the total number of open query windows

Code:

on *:close:?: {
.titlebar Privado N®: $query(0)
}