Part is the same except using $nick and not $knick smile
Code:
on *:part:#:{ 
  if $hget(textcounter. $+ #) { hdel $v1 $nick }
}


For quits, you have to loop through $comchan() because there is no specific channel associated with a quit.
Code:
on *:quit:{
  var %i = 1
  while $comchan($nick,%i) {
    if $hget(textcounter. $+ $v1) { hdel $v1 $nick }
    inc %i
  }
}