improved system shutdown handling