fix: don't write on closed socket