Fixed connection close issues