Fix to avoid IllegalStateException for dismissDialog when we finish activity