curl: Fix infinite loop after canceling a download