Fix problem with unexpected shutdowns