How to extend a generic isomorphism to an isomorphism outside finitely many primes? Let $X,X'$ be normal, proper and flat $\mathbb{Z}$-schemes. Write $X_{\mathbb{Q}}$ for the generic fiber of $X$, i.e. $X_{\mathbb{Q}}:=X \times_{Spec (\mathbb{Z})} Spec (\mathbb{Q})$.
Let us assume that there is an isomorphism $X_{\mathbb{Q}}\cong X'_{\mathbb{Q}}$ of $\mathbb{Q}$-schemes. The following fact seems to be well known:
There exists a finite set of prime numbers $\Sigma=\{p_1,...,p_{n}\} \subset \mathbb{Z}$ such that the above (generic) isomorphism extends to an isomorphism of $\mathbb{Z}(\Sigma^{-1})$-schemes (where $\mathbb{Z}(\Sigma^{-1}):=\mathbb{Z}[p_{1}^{-1},...,p_{n}^{-1}]$), i.e. we have
$$X \times_{Spec(\mathbb{Z})} Spec(\mathbb{Z}(\Sigma^{-1})) \cong X' \times_{Spec(\mathbb{Z})}Spec(\mathbb{Z}(\Sigma^{-1}))$$
Can anyone give me a reference for this statement or, if it seems reasonable, even a (sketch of a) proof?
 A: The morphism $X_{/\mathbb Q} \to X'_{\mathbb Q}$ ultimately involves some explicit polynomials, which have only finitely many primes in the denominators of
their coefficients, and so can be extended over $X_{\mathbb Z(\Sigma^{-1})}$ for a sufficiently large (but finite) set of primes $\Sigma$.  
Likewise for the map in the other direction (enlarging $\Sigma$ if necessary).  Since the composite of the
resulting two morphisms is the identity generically, it it will have to the be the identity (by flatness, say).
If you want a more formal argument, you could do the following:
let $f: X_{\mathbb Q} \to X'_{\mathbb Q}$ be the given morphism,
and form its graph $\Gamma_f \subset (X \times_{\mathbb Z} X')_{\mathbb Q}$.
Now closed up $\Gamma_f$ in $X\times_{\mathbb Z} X'$.  The result is a closed subscheme $Z$ of the product, and the projection of $Z$  onto $X$ is an isomorphism generically (i.e. over Spec $\mathbb Q$)  (since over $\mathbb Q$ this is just the projection of $\Gamma_f$ onto $X_{\mathbb Q}$, and the characteristic property of a graph is that this projection is an isomorphism).
Now check that a morphism between two finite type flat $\mathbb Z$-schemes which is an isomorphism over $\mathbb Q$ is an isomorphism over some open subset  Spec $\mathbb Z(\Sigma^{-1})$ of Spec $\mathbb Z$.  Thus,
over $\mathbb Z(\Sigma^{-1})$ we see that the projection $Z_{\mathbb Z(\Sigma^{-1})} \to X_{\mathbb Z(\Sigma^{-1})}$ is an isomorphism, and so
$Z_{\mathbb Z(\Sigma^{-1})}$ is the graph of some extension $f'$ of $f$ to $X_{\mathbb Z(\Sigma^{-1})}$.
