fix for graceful shutdown