Fix network close events never getting called. Closes #381