added clientapi.close to simplify cleanup