How is it possible to prove this statement?
Let $g:S \to \mathbb{C}$ be a continous function and $S$ a open set. Denoting with $\bar{S}$ the closure of $S$, then
$$\sup_{z \in S} |g(z)|=\sup_{z \in \bar{S}} |g(z)|$$
If $s=\sup_{z \in \bar{S}} |g(z)|$ then by definition $\forall n \geq 1 \,\,\, \exists z_n \in \bar{S} : |g(z_n)|>s-\frac{1}{n}.$ But I'm stuck here and I don't know how it is necessary for the function $g$ to be continuous.
Let: $$ A:=\sup_{z\in S}|g(z)|\qquad\text{and}\qquad B:=\sup_{z\in\overline{S}}|g(z)|. $$ Clearly, $A\leq B$. Now, suppose $z\in \overline{S}$. Choose a sequence $(z_{n})\subset S$ such that $z_{n}\to z$. Since $g$ is continuous, $g(z_{n})\to g(z)$. By definition, $|g(z_{n})|\leq A$ for all $n$. Hence, $$ |g(z)|=\lim_{n\to\infty}|g(z_{n})|\leq A. $$ Since this holds for all $z\in\overline{S}$, it follows that $$ B=\sup_{z\in\overline{S}}|g(z)|\leq A. $$