Fix unsuccessful restoring of a session blocking Krita from closing
BUG: 399203 (cherry picked from commit 715ad1317627a2bdd41241ed772fda705a5beffd)