fix closing and deregistering connection when connect fails (#128)

addressed #128