Fix race in fatal exit & context shutdown.
Fix race in shutdown: context should be shut down in case of error.