close connection automatically on client termination