Solution (source code)

= Solution

The assertion is false without a boundedness or <uniform integrability> condition. Take the upper half-plane
$$
D=\{(x,y)\in\mathbb R^2:y>0\}
$$
and $u(x,y)=y$. This function is harmonic and continuous on $\overline D$, with boundary value $f=0$. The second coordinate of planar Brownian motion is one-dimensional Brownian motion, so its first hitting time $\tau$ of zero is finite almost surely. Nevertheless
$$
u(x,y)=y>0=\mathbb E_{(x,y)}f(B_\tau).
$$
The stopped local martingale $u(B_{t\wedge\tau})$ is not uniformly integrable, which is exactly why optional stopping fails in the limit.