When do regular values form an open set? Let $f:M\to N$ be a $C^\infty$ map between manifolds.

When is the set of regular values of $N$ an open set in $N$?

There is a case which I sort of figured out:


*

*If $\operatorname{dim} M = \operatorname{dim} N$ and $M$ is compact, it is open by the following argument (fixed thanks to user7530 in the comments):


Let $y\in N$. Suppose $f^{-1}(y)\neq \emptyset$. The stack of records theorem applies: $f^{-1}(y)=\{x_1,\dots,x_n\}$ and there is an open neighborhood $U$ of $y$ such that $f^{-1}(U)=\bigcup_{i=1}^n U_i$, with $U_i$ an open neighborhood of $x_i$ such that the $U_i$ are pairwise disjoint and $f$ maps $U_i$ diffeomorphically onto $U$.
Now every point in $f^{-1}(U)$ is regular, since if $x_i'\in U_i$, then $f|_{U_i}:U_i\to U$ diffeomorphism $\Rightarrow$ $df_{x_i'}$ isomorphism (thanks to user 7530 for simplifying the argument).
Now suppose $f^{-1}(y)=\emptyset$. Then there is an open neighborhood $V$ of $y$ such that every value in $V$ has no preimages. Indeed, the set $N\setminus f(M)$ is open, since $M$ compact $\Rightarrow$ $f(M)$ compact, hence closed. Therefore $V$ is an open neighborhood of $y$ where all values are regular, and we are done.


Can we remove the compactness/dimension assumptions in some way?


The set of critical points is closed. You want that the image of this set under $f$ be closed. What about demanding that $f$ is closed? A condition that implies that $f$ is closed is to demand that $f$ is proper (i.e. preimages of compact sets are compact). 
