That would work fine when someone quits, but if they part the channel, leaving the OP alone on the channel, then the OP also wanted to depart the channel, which that code does not incorporate