If you manually close an channel window then you must use the ON *:PART:#: { if ($nick == $me) { do_stuff } } event.