improve shutdown