Fix connection shutdown errors