With the code I saw, the variable that is used to obtain the channel name will be incorrect if the channel is parted.

Here is my recommendation
Code:
alias -l users {
  var %i = 1
  while %i <= $chan(0) {
    var %users = $nick($chan(%i),0)
    if (%users < 3) {
      part $chan(%i)
      dec %i
    }
    inc %i
  }
}


I also recommend using the at1 switches in the scon command.

This will guarantee that you are actually connected to the server before running the alias.