fixed race condition where a go routine would never get closed