Before, when we work with octave and use 'Restart Backend' button, we suddenly get foreign output. So this commit fix it by adding backend cleanup of inner state in logout. Also the commit move `emit loginDone` statement, because we emit this signal **before** we real finish preparation.