Toss two coins until two Heads and two Tails come up
After the first bad event one has $x\geq1$ dollars in the pocket. The question is whether one shall go on playing. Denote by $E(x)$ the expected total win under the best strategy in this situation. If we decide to quit we have won $x$, and if we make a next turn we have (with probability ${3\over4}$) won $x+1$ and the possibility of further play, or (with probability ${1\over4}$) we have won $0$. This shows that $$E(x)=\max\left\{x, \ {3\over4}E(x+1)\right\}\ .\tag{1}$$ I'm assuming (without proof) that there will be an $n$ where we definitely won't play once more; hence $E(n)=n$. From this and $(1)$ we get $$E(n-1)=\max\left\{n-1,\ {3\over4}n\right\}=n-1\qquad(n\geq4)\ .$$ By downwards induction it follows that $$E(n)=n\qquad(n\geq 3)\ .$$ Using $(1)$ one then computes $$E(2)=\max\left\{2,\ {3\over4}E(3)\right\}={9\over4}\ ,\qquad E(1)=\max\left\{1,\ {3\over4}E(2)\right\}={27\over16}\ .$$ This means that one should play on when $1\leq x\leq2$, and quit otherwise.
Suppose you have won $\$x$ by the first bad event, and plan to continue for $y$ more rounds. Then your expected winnings are $$\left(\frac34\right)^y(x+y)$$
For each value of $x$, write down the winnings for the various $y$, and pick the best $y$ for each $x$.