Why the following function is closed?
Hint: you have to show that if $A \subseteq [0, 1] \cup [2, 3]$ is closed, then $p(A)$ is closed. Now $p(A) = p(A \cap [0, 1]) \cup p(A \cap [2, 3])$, which will be closed if $p(A \cap [0, 1])$ and $p(A \cap [2, 3])$ are both closed (that's sufficient, but not necessary, but it will do for this problem). $A$ is closed iff $A \cap [0, 1]$ and $A \cap [2, 3]$ are both closed (do you see why?). Now $p$ restricts to the identity on $[0, 1]$ and to the function $x \mapsto x - 1$ on $[2, 3]$. I'll let you take it from there, by showing that both of these restrictions of $p$ are closed functions.
Hint: Let $A\subseteq X$ be a closed set. Show that $p(A)$ is a closed set. If $\{x_n\}_n\subseteq A$ converges to some $x\in A$ then we have $\{p(x_n)\}_n\subseteq p(A)$. $p$ is continuous (on the appropriate tail of the sequence) thus we must have $\lim p(\{x_n\})=p(\lim\{x_n\})=p(x)$. But since $x\in A$ then $p(x)\in p(A)$.