との事で

やっとのことでyatto no koto de

1 endlich; schließlich.
2 gerade noch; mit Müh und Not; mit Mühe und Not; mit knapper Not.