Let $w = f(x,y,z), z = g(x,y)$, then by chain rule $$\frac{\partial w}{\partial x} = \frac{\partial x}{\partial x}\frac{\partial x}{\partial x} + \frac{\partial w}{\partial y}\frac{\partial y}{\partial x} + \frac{\partial w}{\partial z}\frac{\partial z}{\partial x} = \frac{\partial w}{\partial x} + \frac{\partial w}{\partial z}\frac{\partial z}{\partial x}$$
So $$0 = \frac{\partial w}{\partial z}\frac{\partial z}{\partial x}$$ from which we get $$\frac{\partial w}{\partial z} = 0 \text{ or } \frac{\partial z}{\partial x}=0$$ which obviously is not true in general.
This seems like a problem of notation. A partial derivative really acts on a multivariable function, not two variables. In your question you have three functions:
In the notation $\frac{\partial a}{\partial b}$, we must have $a$ representing some function of a number of independent variables, one of which is $b$. When we write $z = g(x,y)$, then $z$ cannot be independent of $x$ and $y$.
At some specific values of $x$ and $y$, we can find $z = g(x,y)$ and then $w = f(x,y,z)$. But this represents just a collection of specific numbers, and isn't describing the functions themselves. In each $\partial a/\partial b$, we need to know what the independent variables for function $a$ are. Just writing $\partial w/\partial x$ is ambiguous: are we looking just at function $f$ with its three arguments $x,y,z$ independent? Or are we looking at the bigger problem where $z$ is dependent on $x$ and $y$, so only $x$ and $y$ are independent variables?
Writing out the chain rule with function names gives the correct equation:
$$ \begin{align} \frac{\partial h}{\partial x} &= \frac{\partial f}{\partial x} \frac{\partial x}{\partial x} + \frac{\partial f}{\partial y} \frac{\partial y}{\partial x} + \frac{\partial f}{\partial z} \frac{\partial g}{\partial x} \\ \frac{\partial h}{\partial x} &= \frac{\partial f}{\partial x} \cdot 1 + \frac{\partial f}{\partial y} \cdot 0 + \frac{\partial f}{\partial z} \frac{\partial g}{\partial x} \\ \frac{\partial h}{\partial x} &= \frac{\partial f}{\partial x} + \frac{\partial f}{\partial z} \frac{\partial g}{\partial x} \end{align} $$
Note that even though $w = f(x,y,z) = h(x,y)$, it's not true that $\partial f / \partial x = \partial h / \partial x$, which is the problem with "$\partial w / \partial x$".
(I said the top symbol in the partial derivative must be a function. In $\partial x/\partial x$ and $\partial y/\partial x$, we can actually view the symbol on top as a "projection function": $i_x(x,y)=x$, $i_y(x,y)=y$. But usually that's more precise than necessary. If $x$ and $y$ are always independent variables in the context, it's not ambiguous to just say $\partial x/\partial x = 1$ and $\partial y/\partial x = 0$.)