This depends on the optimization algorithm, if only the gradient of the cost function is taken into account, you can get stuck in a saddle point. For this $\
abla f = 0$, but the solution is not a stable point, Consider the situation
$$ f(x) = x^3 $$
Clearly $df(0)/dx = 0$, but $x=0$ is not a stable point of $f$.
![enter image description here](