Close the connection even if an error occured