added delayed gracefull shut down on error