Logic cleanup: closing connections

Signed-off-by: Frank Mertens <frank@cyblogic.de>