minden jó, ha jó a vége

Etymology
Literally: "everything is good if its end is good"