You'd need to use $chan in the users alias...
This code seems to work, but hasn't been tested very well.
alias -l users {
var %i = 1
while %i <= $chan(0) {
var %users $nick($chan(%i),0)
if (%users < 3) { /part $chan(%i) }
inc %i
}
}
That should loop through all the channels, count how many people are there and part if its less than three. I got rid of the halt statement because the while loop needs to continue through to check each channel (and there wasn't a reason it should have been there in the first place as far as I can tell).