Let $f : \mathbb{R} \to \mathbb{R}$ be continuous, everywhere-differentiable, and bounded above by $u$. Let $S_k = \{x | f(x) \le k \}$ (thus, $S_u = \mathbb{R}^n$). Imagine sliding $k$ down continuously from $u$. Then $S_k$ would lose path-connectedness right at the moment that the line $f(x) = k$ becomes tangent to the global maximum $g$ of $f(x)$, since any further decrease in $k$ will cause $g \notin S_k$, and poking a hole in $\mathbb{R}$ causes it to lose path-connectedness.
What is the equivalent condition if we change the domain of $f$ from $\mathbb{R}$ to $\mathbb{R}^n$?