Better shutdown handling?