We first reduce to the Noetherian case. We strongly urge the reader to skip this paragraph. First, we may replace $S$ by $\Spec(\mathbf{Z})$. See Spaces, Section \ref{spaces-section-change-base-scheme} and Properties of Spaces, Definition \ref{spaces-properties-definition-separated}. There exists a closed immersion $X \to X'$ with $X' \to B$ of finite presentation and separated. See Limits of Spaces, Proposition \ref{spaces-limits-proposition-separated-closed-in-finite-presentation}. If we find a compactification of $X'$ over $B$, then taking the scheme theoretic closure of $X$ in this will give a compactification of $X$ over $B$. Thus we may assume $X \to B$ is separated and of finite presentation. We may write $B = \lim B_i$ as a directed limit of a system of Noetherian algebraic spaces of finite type over $\Spec(\mathbf{Z})$ with affine transition morphisms. See Limits of Spaces, Proposition \ref{spaces-limits-proposition-approximate}. We can choose an $i$ and a morphism $X_i \to B_i$ of finite presentation whose base change to $B$ is $X \to B$, see Limits of Spaces, Lemma \ref{spaces-limits-lemma-descend-finite-presentation}. After increasing $i$ we may assume $X_i \to B_i$ is separated, see Limits of Spaces, Lemma \ref{spaces-limits-lemma-descend-separated-morphism}. If we can find a compactification of $X_i$ over $B_i$, then the base change of this to $B$ will be a compactification of $X$ over $B$. This reduces us to the case discussed in the next paragraph. \medskip\noindent Assume $B$ is of finite type over $\mathbf{Z}$ in addition to being quasi-compact and quasi-separated. Let $U \to X$ be an \'etale morphism of algebraic spaces such that $U$ has a compactification $Y$ over $\Spec(\mathbf{Z})$. The morphism $$ U \longrightarrow B \times_{\Spec(\mathbf{Z})} Y $$ is separated and quasi-finite by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-monomorphism-loc-finite-type-loc-quasi-finite} (the displayed morphism factors into an immersion hence is a monomorphism). Hence by Zariski's main theorem (More on Morphisms of Spaces, Lemma \ref{spaces-more-morphisms-lemma-quasi-finite-separated-pass-through-finite}) there is an open immersion of $U$ into an algebraic space $Y'$ finite over $B \times_{\Spec(\mathbf{Z})} Y$. Then $Y' \to B$ is proper as the composition $Y' \to B \times_{\Spec(\mathbf{Z})} Y \to B$ of two proper morphisms (use Morphisms of Spaces, Lemmas \ref{spaces-morphisms-lemma-finite-proper}, \ref{spaces-morphisms-lemma-composition-proper}, and \ref{spaces-morphisms-lemma-base-change-proper}). We conclude that $U$ has a compactification over $B$. \medskip\noindent There is a dense open subspace $U \subset X$ which is a scheme. (Properties of Spaces, Proposition \ref{spaces-properties-proposition-locally-quasi-separated-open-dense-scheme}). In fact, we may choose $U$ to be an affine scheme (Properties, Lemmas \ref{properties-lemma-Noetherian-irreducible-components} and \ref{properties-lemma-maximal-points-affine}). Thus $U$ has a compactification over $\Spec(\mathbf{Z})$; this is easily shown directly but also follows from the theorem for schemes, see More on Flatness, Theorem \ref{flat-theorem-nagata}. By the previous paragraph $U$ has a compactification over $B$.  By Noetherian induction we can find a maximal dense open subspace $U \subset X$ which has a compactification over $B$. We will show that the assumption that $U \not = X$ leads to a contradiction. Namely, by Lemma \ref{lemma-filter-Noetherian-space} we can find a strictly larger open $U \subset W \subset X$ and a distinguished square $(U \subset W, f : V \to W)$ with $V$ affine and $U \times_W V$ dense image in $U$. Since $V$ is affine, as before it has a compactification over $B$. Hence Lemma \ref{lemma-two-compactifications} applies to show that $W$ has a compactification over $B$ which is the desired contradiction.