Stability fix to make sure dialog does not get deallocated while its cleanup runs