亡羊補牢

Etymology
From :

This is also the origin for the idiom.

Idiom

 * 1) to close the stable door after the horse has bolted; to act belatedly