Fix client timeout logic

Fixes issue #8580 and #7157 as far as I can tell from testing.

Also DRY. I'm not making the same changes in get_iter_returns(), get_returns(), and get_cli_event_returns(). They are exactly the same code (+- 1 line).