build: improve shutdown behavior in errors