Suppose we have a closed subscheme $X \subset S$ such that $X \cap (S \setminus Z) = U'$ and $X_{/Z} = W$. Then $X$ represents the functor $F$ (some details omitted) and hence  is a solution. To find $X$ is clearly a local question on $S$. In this way we reduce to the case discussed in the next paragraph. \medskip\noindent Assume $S = \Spec(A)$ is affine. Let $I \subset A$ be the radical ideal cutting out $Z$. Write $I = (f_1, \ldots, f_r)$. By assumption we are given \begin{enumerate} \item the closed immersion $U' \to S \setminus Z$ determines ideals $J_i \subset A[1/f_i]$ such that $J_i$ and $J_j$ generate the same ideal in $A[1/f_if_j]$, \item the closed immersion $W \to S_{/Z}$ is the map $\text{Spf}(A^\wedge/J') \to \text{Spf}(A^\wedge)$ for some ideal $J' \subset A^\wedge$ in the $I$-adic completion $A^\wedge$ of $A$. \end{enumerate} To finish the proof we need to find an ideal $J \subset A$ such that $J_i = J[1/f_i]$ and $J' = JA^\wedge$. By More on Algebra, Proposition \ref{more-algebra-proposition-equivalence} it suffices to show that $J_i$ and $J'$ generate the same ideal in $A^\wedge[1/f_i]$ for all $i$. \medskip\noindent Recall that $A' = H^0(X', \mathcal{O})$ is a finite $A$-algebra whose formation commutes with flat base change (Cohomology of Spaces, Lemmas \ref{spaces-cohomology-lemma-proper-over-affine-cohomology-finite} and \ref{spaces-cohomology-lemma-flat-base-change-cohomology}). Denote $J'' = \Ker(A \to A')$\footnote{Contrary to what the reader may expect, the ideals $J$ and $J''$ won't agreee in general.}. We have $J_i = J''A[1/f_i]$ as follows from base change to the spectrum of $A[1/f_i]$. Observe that we have a commutative diagram $$ \xymatrix{ X' \ar[d] & X'_{/T'} \times_{S_{/Z}} \text{Spf}(A^\wedge) \ar[l] \ar[d] & X'_{/T'} \times_W \text{Spf}(A^\wedge/J') \ar@{=}[l] \ar[d] \\ \Spec(A) & \text{Spf}(A^\wedge) \ar[l] & \text{Spf}(A^\wedge/J') \ar[l] } $$ The middle vertical arrow is the completion of the left vertical arrow along the obvious closed subsets. By the theorem on formal functions we have $$ (A')^\wedge = \Gamma(X' \times_S \Spec(A^\wedge), \mathcal{O}) = \lim H^0(X' \times_S \Spec(A/I^n), \mathcal{O}) $$ See Cohomology of Spaces, Theorem \ref{spaces-cohomology-theorem-formal-functions}. From the diagram we conclude that $J'$ maps to zero in $(A')^\wedge$. Hence $J' \subset J'' A^\wedge$. Consider the arrows $$ X'_{/T'} \to \text{Spf}(A^\wedge/J''A^\wedge) \to \text{Spf}(A^\wedge/J') = W $$ We know the composition $g$ is a formal modification (in particular rig-\'etale and rig-surjective) and the second arrow is a closed immersion (in particular an adic monomorphism). Hence $X'_{/T'} \to \text{Spf}(A^\wedge/J''A^\wedge)$ is rig-surjective and rig-\'etale, see Algebraization of Formal Spaces, Lemmas \ref{restricted-lemma-rig-surjective-alternative-permanence} and \ref{restricted-lemma-rig-etale-alternative-permanence}. Applying Algebraization of Formal Spaces, Lemmas \ref{restricted-lemma-rig-etale-descent} and \ref{restricted-lemma-permanence-rig-surjective} we conclude that $\text{Spf}(A^\wedge/J''A^\wedge) \to W$ is rig-\'etale and rig-surjective. By Algebraization of Formal Spaces, Lemma \ref{restricted-lemma-closed-immersion-rig-smooth-rig-surjective} we conclude that $I^n J'' A^\wedge \subset J'$ for some $n > 0$. It follows that $J'' A^\wedge[1/f_i] = J' A^\wedge[1/f_i]$ and we deduce $J_i A^\wedge[1/f_i] = J' A^\wedge[1/f_i]$ for all $i$ as desired.