Fixed channel closing before waiting for thread to quit.