adding a nice shutdown after each error