diff --git a/admin/tool/task/schedule_task.php b/admin/tool/task/schedule_task.php
index <HASH>..<HASH> 100644
--- a/admin/tool/task/schedule_task.php
+++ b/admin/tool/task/schedule_task.php
@@ -83,6 +83,8 @@ if (!optional_param('confirm', 0, PARAM_INT)) {
 // Action requires session key.
 require_sesskey();
 
+\core\session\manager::write_close();
+
 // Prepare to handle output via mtrace.
 echo html_writer::start_tag('pre');
 $CFG->mtrace_wrapper = 'tool_task_mtrace_wrapper';
MDL-<I> tool_task: Unlock session on long running tasks in UI