When is the fiberwise compactification (not) equal to the compactification of the family? Suppose $\pi:\mathcal{X}\rightarrow S$ is a smooth family of complex affine varieties (to make things simpler, we can actually assume it is locally trivial). Let $P$ be a smooth projective variety, and assume there is an embedding $\mathcal{X}\hookrightarrow P\times S$ over $S$. Let $\overline{\pi}: \overline{\mathcal{X}}\rightarrow S$ be the projection for the closure of $\mathcal{X}$ in $P\times S$. Is it always true that for every (closed) point $s\in S$, $\overline{\pi^{-1}(s)}=\overline{\pi}^{-1}(s)$? Any references will be greatly appreciated.
 A: No.
Let $S = \mathbb{A}^1_{\mathbb{C}}$ and $\mathcal{X} = \mathbb{A}^1_S \rightarrow S$ be the constant family. Let $\mathcal{Y}$ be the blow-up of the surface $\mathbb{P}^1_S$ at the closed point over $0\in S$ lying at infinity. In other words: $\mathbb{P}^1_S = \mathbb{P}^1\times \mathbb{A}^1$ and $\mathcal{Y}$ is the blow-up at the point $(\infty,0)$.
Since blowing-up is an isomorphism away from the exceptional locus, there is an open immersion $\mathcal{X} \hookrightarrow \mathcal{Y}$ of $S$-schemes. Since $\mathcal{Y}$ is irreducible, $\mathcal{X}$ is dense in $\mathcal{Y}$.
Since the morphisms $\mathcal{Y} \rightarrow \mathbb{P}^1_S$ and $\mathbb{P}^1_S \rightarrow S$ are projective, the composite $\mathcal{Y} \rightarrow S$ is projective as well. Choose $n \geq 0$ large enough such that there exists a closed embedding $\mathcal{Y} \hookrightarrow P_S$, where $P = \mathbb{P}^n_{\mathbb{C}}$. The closure $\bar{\mathcal{X}}$ of $\mathcal{X}$ in $P_S$ is exactly $\mathcal{Y}$.
The fibre of $\mathcal{Y} \rightarrow S$ above $0$ is a union of two projective lines. However, the fibre of $\mathcal{X} \rightarrow S$ above $0$ is just $\mathbb{A}^1$. Therefore $\mathcal{X}_0$ is not dense in $(\bar{\mathcal{X}})_0$, as required.
