Close session only if encryption app is not enabled

Fixes https://github.com/owncloud/core/issues/12389

@schiesbn @th3fallen Please test.