Critical asymptotic behavior for the Korteweg-de Vries equation and in random matrix theory