When Casimir meets Kibble–Zurek