fix bug: close handleWrite routine.