# Stalks and closed immersion

I have a very simple question regarding calculating the stalk of a certain sheaf: I refer to Proposition 2.24 (and also Lemma 2.23) of Liu's Algebraic Geometry. Suppose we have $$(f,f^\sharp):(Y,\mathcal{O}_Y)\rightarrow(X,\mathcal{O}_X)$$ a closed immersion of ringed topological spaces. Liu states that, being $f(Y)\subseteq X$ closed, we can deduce that $$f_*\mathcal{O}_{Y,x}=\begin{cases}0&\mbox{if }x\notin f(Y)\\\mathcal{O}_{Y,y}&\mbox{if }x=f(y)\end{cases}$$ How do we get that from the definition of stalk? If $x\in f(Y)$ then $$\varinjlim_{x\in U} (f_*\mathcal{O}_Y)(U)=\varinjlim_{x\in U} \mathcal{O}_Y(f^{-1}(U))=\varinjlim_{f^{-1}(x)\in V} \mathcal{O}_Y(V)=\mathcal{O}_{Y,f^{-1}(x)}$$ but what about the first row? I guess it holds because, being $f(Y)$ closed, if $x\notin f(Y)$ then at some point we "fall out of it" in the system of open sets containing $x$ and thus the sections become all zero, but what is the rigorous explanation?

Suppose $x\notin f(Y)$, and let $g_x\in f_*\mathcal O_{Y,x}$. Then $g_x$ is the germ of some $g\in\mathcal f_*O_Y(U)$ for some open neighborhood $U$ of $x$. But note that by assumption $V:=X\smallsetminus f(Y)$ is also an open neighborhood of $x$, so the germ of $g$ is the same as the germ of $$g|_{U\cap V}\in f_*\mathcal O_Y(U\cap V)=\mathcal O_Y(f^{-1}(U\cap V))=\mathcal O_Y(\varnothing)=0.$$
Hence we see that $g_x=0$.