(Old fashioned) Useless and stupid endeavor. Obviously, if the horse has escaped the barn, then locking the door is a useless reaction and of no value, so this phrase is used to describe any fruitless actions to curb a problem. (Compare to For naught.)
Lock the barn door after the horse gets out
DEFINITION