Good suggestion, I dont think there is a command to close the channel window without it directly coming from the server, for obvious reasons, but maybe there should be.
You could try something like:
raw *:*:{
if (($chan($4)) && (($numeric == 442) || ($numeric == 403))) {
.window -h $4
}
}
Which checks if the numerics are 442 (not on channel), or 403 (channel doesnt exist), and then checks if the window for that channel is actually open, if it is, it will hide the window from the switchbar.
On me:*:join:#:{
if ($window($chan).state == hidden) {
window -w $chan
}
}
Which makes the channel "visible" when you join it again.
Eamonn.