fixed race condition related to exit and double use of channel