Let $M$ be a closed subspace of a Hilbert space $H$ and $A \in B(H)$ with $|A| = (A^* A)^{1/2}$.
$\textbf{Lemma 1:}$ $AM$ is closed if and only if $|A|M$ is closed.
$\textbf{Proof:}$ Observe that $\|Ax\| = \||A|x\|$ for any $x \in H$. Suppose $AM$ is closed and consider a sequence $\{x_n\} \subseteq M$ such that $\||A|x_n - y_0\| \to 0$ for some $y_0 \in H$. Since $\{ |A|x_n \}$ is a Cauchy sequence, $\{ Ax_n \}$ is also. Therefore, there exists $x_0 \in M$ such that $\|Ax_n - Ax_0\| \to 0$ and $\||A|x_n - |A|x_0\| \to 0$. Thus, $y_0 = |A|x_0 \in |A|M$. The converse follows similarly.
$\textbf{Lemma 2:}$ If both $M$ and $M^\perp$ are of infinite dimension, there exists a closed subspace $\hat{M}$ such that $(B \oplus 0)\hat{M}$ is not closed for any invertible $B \in B(M)$.
$\textbf{Proof:}$ Assume $P = I_M \oplus 0$ is the projection onto $M$. Let $\{e_k\}$ and $\{f_k\}$ be orthonormal bases of $M$ and $M^\perp$, respectively. Define $\hat{M} = \bigvee \left\{\frac{1}{\sqrt{k}} e_k + \sqrt{\frac{k-1}{k}} f_k\right\}_{k=1}^\infty$. For each $k$, $e_k = \sqrt{k}P\left(\frac{1}{\sqrt{k}} e_k + \sqrt{\frac{k-1}{k}} f_k\right)$ belongs to $P\hat{M}$. If $P\hat{M}$ is closed, then $M \subseteq P\hat{M}$ and $\sum_{k=1}^\infty \frac{e_k}{k} \in P\hat{M}$. Note that $\left\{\frac{1}{\sqrt{k}} e_k + \sqrt{\frac{k-1}{k}} f_k\right\}$ is an ONB of $\hat{M}$ and let $x = \sum_{k=1}^\infty \lambda_k \left(\frac{1}{\sqrt{k}} e_k + \sqrt{\frac{k-1}{k}} f_k\right) \in \hat{M}$ such that $Px = \sum_{k=1}^\infty \frac{e_k}{k}$. Comparing coefficients shows that $x = \sum_{k=1}^\infty \frac{1}{k} e_k + \frac{\sqrt{k-1}}{k} f_k$. Since $\sum_{k=1}^\infty \frac{k-1}{k^2} = \infty$, we reach a contradiction.
If $B \in B(M)$ is invertible then $B\oplus I_{M^\perp}\in B(H)$ is invertible and therefore a homeomorphism. So $\left(B\oplus 0\right)\hat{M}=\left(B\oplus I_{M^\perp}\right)\left(I_M\oplus 0\right)\hat{M}$ is not closed.
$\textbf{Proof of the question:}$ Assume $AM$ is closed for every closed subspace $M$ (implying that $\operatorname{ran} A$ is closed). Then, we have $\operatorname{ker} A^\perp = \operatorname{ker} |A|^\perp = \operatorname{ran} |A|$.
\begin{aligned}
|A| &= \vcenter{\hbox{$
\begin{matrix}
\operatorname{ker} |A|^\perp & \operatorname{ker} |A|
\end{matrix}\\
\begin{bmatrix}
\phantom{\operatorname{ran}} A_0 & \phantom{\operatorname{ran}} 0 \phantom{\operatorname{ran}}\\
\phantom{\operatorname{ran}} 0 & \phantom{\operatorname{ran}} 0 \phantom{\operatorname{ran}}
\end{bmatrix}
\begin{matrix}
\operatorname{ker} |A|^\perp\\
\operatorname{ker} |A|
\end{matrix}
$}}
\end{aligned}
Where $A_0 \in B(\operatorname{ker} |A|^\perp)$ is invertible. By Lemma 2, either $\operatorname{ker} |A|$ or $\operatorname{ker} |A|^\perp$ has finite dimension. In the first case, $\operatorname{ker} A = \operatorname{ker} |A|$ has finite dimension, making $A$ a left Fredholm operator. In the second case, $\operatorname{ran} A^* = \operatorname{ker} A^\perp = \operatorname{ker} |A|^\perp$ is of finite dimension, and therefore, $\operatorname{ran} A$ is also of finite dimension ($A$ has finite rank implies $A^*$ has finite rank. Also $A$ compact implies $A^*$ compact.).