Added a detach part to the errorTerminate function