On the Stability of Nonlinear Dynamics in GD and SGD: Beyond Quadratic Potentials