Fix an issue where callbacks could be double-called when there was an exception.