fix connection close order
cleanup on close