Unique, Continuous, Surjective, Closed Extension of Identity from Stone-Čech Compactification to Compactification I have woven the below incomplete proof of the following claim:

Claim. If $X$ is completely regular and $Y$ is a compactification of $X$,
  then there is a unique, continuous, surjective, closed map
  $g:\beta\left(X\right)\to Y$ which is the identity on
  $X$.

Here, $\beta\left(X\right)$ is the Stone-Čech compactification of $X$.
Proof. Let $f:X\to Y$ be such that $x\mapsto x$. Then $f$ is continuous. Since $f$ is continuous and $Y$ is compact and Hausdorff, it is the case that $f$ extends uniquely to a continuous map $g:\beta\left(X\right)\to Y$. Then $g$ is the identity on $X$. Let $C\subseteq\beta\left(X\right)$ be closed. Since $\beta\left(X\right)$ is compact, it is the case that $C$ is compact. Since $g$ is continuous, it is the case that $g\left(C\right)$ is compact. Since $Y$ is Hausdorff, it is the case that $g\left(C\right)$ is closed. Then $g$ is closed...
I do not know how to show that $g$ is surjective. Am I allowed to use the "maximality" of $\beta\left(X\right)$? If so, then I believe that it would follow that $Y\subseteq\beta\left(X\right)$, which would imply that $g$ is surjective. I am not sure because this "maximality" is not defined in terms of containment.
 A: There is one important fact you still haven't used: namely, that $Y$ is a compactification of $X$, which means not just that $X\subseteq Y$ and $Y$ is compact Hausdorff but that $X$ is dense in $Y$.  As you have shown, $g$ is a closed map.  In particular, taking $C=\beta X$, the image of $g$ is closed.  But the image of $g$ contains $X$, so the image of $g$ must be all of $Y$ since $X$ is dense in $Y$.
A: Suppose that $f[X]\subsetneqq Y$, let $U=Y\setminus f[\beta X]$, and fix $y\in U$. Then $U$ is an open nbhd of $y$ in $Y$, and $f[X]$ is dense in $Y$, so $U\cap f[X]\ne\varnothing$. Do you see the contradiction?
You’re right to worry about assuming that $Y\subseteq\beta X$: it need not be true, because — as you say — maximality has a different meaning here.
A: You proved the existence of a continuous closed surjection $g:\beta X\to Y$ with $g|_X=id_X.$ You did not explicitly prove  the uniqueness of such a  $g.$ 
If $f_1:A\to B$ and $f_2:A\to B$ are continuous and $B$ is Hausdorff then $\{x\in A: f_1(x)=f_2(x)\}$ is closed in $A.$ 
In particular if $g_1:\beta X\to Y$ is continuous and $g_1|_X=id_X$ then $$\{x\in \beta X:g(x)=g_1(x)\}\supset Cl_{\beta X}(X)=\beta X.$$
