implemented connection closing