"Comeuppance", perhaps? One will often hear it used in the sort of setting you describe.