close connection when failed