change where the channel is closed to prevent race