Added more debugging around shutdown.