From the classical to the quantum Kibble-Zurek scaling