  Let $\mathcal C$ be a class of Hausdorff topological semigroups which
contains all zero-dimensional Hausdorff topological semigroups. A semigroup $X$
is called $\mathcal C$-$closed$ if $X$ is closed in each topological semigroup
$Y\in \mathcal C$ containing $X$ as a discrete subsemigroup; $X$ is
$projectively$ $\mathcal C$-$closed$ if for each congruence $\approx$ on $X$
the quotient semigroup $X/_\approx$ is $\mathcal C$-closed. A semigroup $X$ is
called $chain$-$finite$ if for any infinite set $I\subseteq X$ there are
elements $x,y\in I$ such that $xy\notin\{x,y\}$. We prove that a semigroup $X$
is $\mathcal C$-closed if it admits a homomorphism $h:X\to E$ to a chain-finite
semilattice $E$ such that for every $e\in E$ the semigroup $h^{-1}(e)$ is
$\mathcal C$-closed. Applying this theorem, we prove that a commutative
semigroup $X$ is $\mathcal C$-closed if and only if $X$ is periodic,
chain-finite, all subgroups of $X$ are bounded, and for any infinite set
$A\subseteq X$ the product $AA$ is not a singleton. A commutative semigroup $X$
is projectively $\mathcal C$-closed if and only if $X$ is chain-finite, all
subgroups of $X$ are bounded and the union $H(X)$ of all subgroups in $X$ has
finite complement $X\setminus H(X)$.
