This is a port of PR #1652/#1660. The code in the 2.1.x branch
is not sensitive to the issue fixed in these PRs because marking
the connection as closed (for instance due to a TCP error in
sendProtoNow) will not set `c.nc` to nil, so there won't be
the nil dereference issue that was found in the main branch.
However, porting the code for extra safety.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>