fix infinite loop on client close and keep_alive enabled