an event for all cases: no. but for most cases you can count on an ACTIVE event triggering:
on *:active:*:{
if (!$cid($lactivecid)) {
; connection ID $lactivecid was just closed
}
; check if $cid has been saved before, then save it etc. to detect a new window
}
unfortunately this doesn't detect things like windows opened via /server -z, or closed when all other windows are minimized, etc.
you should always try to tie in the actions with your /close, /window and /server commands wherever possible. in general, and as ugly as it sounds, a timer is your only failsafe option. using a delay as high as possible (consider if you need to detect open/close very quickly, if you can afford to be imprecise) and checking for changes in $scon(0) should be relatively low impact.