add synchronization at closing http client to avoid race condition
move the flag for finished to watchdog
add flag for finished