Add checks for transport connected state so that we don't try and wait
for close if the transport is down.