TITLE: For which matrices $A \in \mathscr{M}_n(\mathbb C)$ is the similarity class of $A$ closed?
QUESTION [7 upvotes]: What are the matrices $A \in \mathscr{M}_n(\mathbb C)$ for which the similarity class is closed?
What about the same question if we replace $\mathbb C$ by $\mathbb R$?

REPLY [3 votes]: $\newcommand{\cj}{\operatorname{cj}} \newcommand{\diag}{\operatorname{diag}}\newcommand{\nil}{\operatorname{nil}}\newcommand{\Spec}[1]{\operatorname{Spec}\left({#1}\right)}$
Complex case:
Let us prove/recall a lemma:

Lemma 1: The function $\dim\ker:\mathscr M_n(\mathbb C)\to \mathbb N$ is upper-semicontinuous, i.e.
  $$\lim_{s\to\infty}M_s= M\implies\dim\ker(M)\ge \limsup_{s\to\infty}\,\dim\ker M_s$$

Indeed, let $q=\limsup_{s\to\infty}\dim\ker M_s$. This means that there exists a sub-sequence $M_{s_h}=M'_h$ such that $\dim\ker M'_h=q$.
Let us consider the standard hermitian product on $\mathbb C^n$ and let us pick $(v_1^h,\cdots,v_q^h)$ an orthonormal basis of $\ker M'_h$.
Recall that $S^{2n-1}=\{v\in \mathbb C^n\, :\, \Vert v\Vert =1\}$. The sequence $$\{(v_1^h,\cdots,v_q^h)\}_{h\in\mathbb N}\subseteq \underbrace{S^{2n-1}\times\cdots\times S^{2n-1}}\limits_{q\text{ times}}$$
has values in a compact subspace of $\mathbb C^{qn}$, therefore it admits a converging subsequence.
So, we have a subsequence $(v^{h_r}_1,\cdots,v^{h_r}_q)\to_r (w_1,\cdots, w_q)$. By continuity of the hermitian product, the latter is a family of orthonormal vectors, hence independent.
Let's call $M^{\prime\prime}_r=M_{h_r}'$
Now, 
\begin{align}\Vert Mw_j\Vert=\Vert Mw_j-M_r''v^{h_r}_j\Vert&\le \Vert (M-M_r'')w_j\Vert +\Vert M_r''(w_j-v_j^{h_r})\Vert\le\\&\le \Vert M-M_r''\Vert\cdot\Vert w_j\Vert +\left(\sup_r\Vert M_r''\Vert\right)\cdot\Vert w_j-v^{h_r}_j\Vert\stackrel{r\to\infty}{\longrightarrow} 0\end{align}
So $Mw_1=Mw_2=\cdots=Mw_q=0$, hence $\dim\ker M\ge q$. $\square$

Back to our problem: The answer is: $\cj A$ is closed if and only if $A$ is diagonalizable.

If part: $A\text{ diagonalizable}\implies \cj A=\overline{\cj A}$
Indeed, let $\Spec{A}=\{\lambda_1,\cdots,\lambda_k\},\ k\le n$ its dinstinct eigenvalues. Let $\dim\ker(A-\lambda_sI)=m_s$. 
Since $A$ is diagonalizable, it holds $$M\in\cj A\iff \forall s=1,\cdots, k,\ \dim\ker(M-\lambda_sI)=m_s$$
Let $\{A_h\}_{h\in \mathbb N}\subseteq \cj A$ a converging sequence $$A_h\to B$$
Then, for all $s$, $A_h-\lambda_sI\to_h B-\lambda_sI$.
By lemma 1, $\dim\ker (B-\lambda_sI)\ge m_s$. But $$n=\sum_{s=1}^k m_s\le\sum_{s=1}^k\dim\ker(B-\lambda_sI)\le n$$ so the only possible choice is $\forall s,\ \dim\ker (B-\lambda_sI)=m_s$. Hence, $B\in\cj A$.
Only if part: $ \cj A=\overline{\cj A}\implies A\text{ diagonalizable}$
The diagonalizable+nilpotent decomposition $A=\diag A+\nil A$ yelds that for all $\varepsilon>0,\ \diag A+\varepsilon\cdot \nil A\in \cj A$. But then $\diag A\in\overline{\cj A}=\cj A$. So $A$ is diagonalizable. $\square$
Real case: 
The fact that $\mathscr{M}_n(\mathbb R)$ is embedded in $\mathscr M_n(\mathbb C)$ and that, for all $A\in\mathscr{M}_n(\mathbb R),\  \cj_{\mathbb R}(A)=\cj_{\mathbb C}(A)\cap \mathscr{M}_n(\mathbb R)$ yields that a real matrix which can be diagonalized in $\mathbb C$ has closed real similarity class. The same trick used for the converse in the complex case can be adapted to fit the real case, considering the real Jordan form, as user1551 recalled.