improve shutdown & exception handling