diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index aa58e33e9d2aceda38336b3f5b4f12041798a11c..3daaa06425faf30dcbb5b65c7a6334780bb75f06 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -134,6 +134,14 @@ class Session {
 
 	}
 
+	/**
+	 * @brief remove encryption keys and init status from session
+	 */
+	public function closeSession() {
+		\OC::$session->remove('encryptionInitialized');
+		\OC::$session->remove('privateKey');
+	}
+
 
 	/**
 	 * @brief Gets status if we already tried to initialize the encryption app
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index ec06bd52f5e7b85b8052eade98f527dc74d95575..6bf69cd8ee194b5dfa0d1bbf93488f2084fe8899 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1772,4 +1772,12 @@ class Util {
 		return $session;
 	}
 
+	/*
+	 * @brief remove encryption related keys from the session
+	 */
+	public function closeEncryptionSession() {
+		$session = new \OCA\Encryption\Session($this->view);
+		$session->closeSession();
+	}
+
 }
diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php
index d7c104ab1517a854ca586bf0b61ea7be674bd500..4782a4cfc81c98039f7d555bb4b6a9363d1be861 100644
--- a/settings/ajax/decryptall.php
+++ b/settings/ajax/decryptall.php
@@ -24,6 +24,8 @@ if ($result !== false) {
 		$successful = false;
 	}
 
+	$util->closeEncryptionSession();
+
 	if ($successful === true) {
 		\OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
 	} else {