First point: in most of the cases, the QPE algorithm cannot output the integer $x$. That is why $w$ is introduced in the algorithm: to represent the closest approximation of $x$ that can be returned by the QPE.
About your question, no the QPE is not always 100% successful (in this case successful means that the algorithm returns $w$, the closest approximation of $x$ possible on $n$ qubits).
The final state of the QPE before measurement is given by (according to Wikipedia):
$$
\frac{1}{2^{n}} \sum_{x=0}^{2^n - 1} \sum_{k=0}^{2^n - 1} e^{-\frac{2\pi i k}{2^n} \left ( x-w \right )} e^{2 \pi i \delta k} |x\rangle \otimes |\psi\rangle.
$$
where:
- $n$, $w$, and $x$ are defined as in your question.
- $\delta = \left\vert \frac{x}{2^n} - w \right\vert = \left\vert \frac{x}{2^n} - \text{round}\left(\frac{x}{2^n}\right) \right\vert$ is the error due to the finite representation of $w$.
I will not rewrite all the calculations, but you can check on the intermediate results on the Wikipedia page.
The probability of getting the right result $w$ when measuring is then
$$
\Pr(w) = \left | \left \langle w \underbrace{\left | \frac{1}{2^{n}} \sum_{x=0}^{2^n-1} \sum_{k=0}^{2^n-1} e^{\frac{-2\pi i k}{2^n}(x-w)} e^{2 \pi i \delta k} \right |}_{\text{State of the first register}} x \right \rangle \right |^2 = \frac{1}{2^{2n}} \left | \sum_{k=0}^{2^n-1} e^{2 \pi i \delta k} \right |^2 = \begin{cases}1 & \delta = 0\\ & \\ \frac{1}{2^{2n}} \left | \frac{1- {e^{2 \pi i 2^n \delta}}}{1-{e^{2 \pi i \delta}}} \right|^2 & \delta \neq 0 \end{cases}
$$
So:
- if the result $x$ can be represented exactly on $n$ qubits (i.e. $\delta$, the error, is $0$), the QPE succeed with a probability of $1$,
- but if $n$ bits are not enough to represent exactly $x$, the QPE might fail.
I tried quickly to derive the expression of your book from the one found on Wikipedia, without success but when the error $\delta$ tends to $0$, both formulas have the same behaviour: the probability of error is $ \sim \mathcal{O}\left( \frac{1}{2^{2n} \delta^2} \right)$.
We can simplify further this big-$\mathcal{O}$ notation by noticing that, by construction, $\delta \leqslant \frac{1}{2^{n+1}}$. The final probability of error is then
$$
\Pr(\text{measurement not returning } \vert w \rangle) \sim \mathcal{O}\left( \frac{1}{2^{4n+1}} \right)
$$
This means that, when you increase the number of qubits $n$ used to represent the solution by $1$, the probability of the QPE returning a bad result is divided by $16$[1].
[1]: There are constants ignored by the big-$\mathcal{O}$ notation that change this value of $16 = 2^4$ to something like $\frac{2^5}{\pi^2} = \frac{32}{\pi^2}$. The additional factor of $2$ in the previous constant is needed to bound the expression $\left\vert 1- {e^{2 \pi i 2^n \delta}} \right\vert$ found for $\Pr(w)$ above but is not needed for the expression given in your book.