diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
index 3f29f1e5eff8a122860eddfb5808b428704ae076..39130a6a983f2ec3db0127dc559410f8ac0fc71b 100644
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -11,6 +11,7 @@ require_once('when/When.php');
 
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('calendar');
+session_write_close();
 
 // Look for the calendar id
 $calendar_id = null;