Please comment the full if (IsRunning()) block here and let us know if it crashes again.
if (IsRunning())