fixed bad select logic for graceful shutdown.