Fix leaking FD

See #1289 
+1 waitgroup is better