close connection when then command execution finished