diff --git a/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java b/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java
index 0d9723be73aaa821b673a4a846debf167d6280dc..9249c3b83471b6786c7289a49179b0fa7ff52a5f 100644
--- a/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java
+++ b/src/main/java/org/olat/core/commons/modules/bc/FolderRunController.java
@@ -429,7 +429,11 @@ public class FolderRunController extends BasicController implements Activateable
 	}
 
 	private void enableDisableQuota(UserRequest ureq) {
-		if (!ureq.getUserSession().getRoles().isOLATAdmin()) {
+		//prevent a timing condition if the user logout while a thumbnail is generated
+		if (ureq.getUserSession() == null || ureq.getUserSession().getRoles() == null) {
+			folderContainer.contextPut("editQuota", Boolean.FALSE);
+			return;
+		} else if (!ureq.getUserSession().getRoles().isOLATAdmin()) {
 			if (!ureq.getUserSession().getRoles().isInstitutionalResourceManager()) {
 				folderContainer.contextPut("editQuota", Boolean.FALSE);
 				return;