best way to optimize shutdown