improve connection closing