Yes, it does apply. The most general version of the theorem requires you to have a uniformly integrable right-continuous martingale, and an arbitrary stopping time. Hence, even if the stopping time is not finite, by the Martingale Convergence Theorem, your martingale converges almost surely and in $L^1$ to some almost surely finite limit $M_ \infty$, and is closed so that $\mathbb{E}[M_\infty|\mathscr{F}_t] = M_t$. This will take care of the cases when the stopping time blows up.
A bounded martingale is a special case of a uniformly integrable martingale, so the theorem applies even if the stopping time is unbounded.
Finally, another common version of the theorem is when $T$ is a bounded stopping time and $M$ is any right-continuous martingale, not necessarily uniformly integrable. This follows from the Optional Stopping Theorem above applied to the martingale $(M_{t \wedge a})_{t \geq 0}$ where $a$ is any real number bigger than the bound of $T.$ The result will follow as this martingale is closed by $M_a$ by the Martingale Convergence Theorem.
Summary: You either want your martingale to be "nice" (eg. uniformly integrable) or your stopping times to be sufficiently "small" (eg. bounded). You generally don't need both.
For details on all of the above, see for example Le Gall's book "Brownian Motion, Martingales, and Stochastic Calculus".