Close connection on error. Return promise on error.