The em.Close() method is waiting on that channel. When it gets a response it knows that the run() goroutine has exited. Of course the listenAndDispatch() thing is still running. I need a clean way to shut that down. Hence the TODO comment on line 202.