graceful shutdown bugfixes