diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php
index <HASH>..<HASH> 100644
--- a/mod/quiz/report/overview/report.php
+++ b/mod/quiz/report/overview/report.php
@@ -607,17 +607,18 @@ document.getElementById("noscriptmenuaction").style.display = "none";
                     echo "</td>\n";
                     echo '</tr></table>';
                 }
-            } else if ($download == 'Excel' or $download == 'ODS') {
-                $workbook->close();
-                exit;
-            } else if ($download == 'CSV') {
-                exit;
             }
         } else {
             if (!$download) {
                 $table->print_html();
             }
         }
+        if ($download == 'Excel' or $download == 'ODS') {
+            $workbook->close();
+            exit;
+        } else if ($download == 'CSV') {
+            exit;
+        }
         if (!$download) {
             // Print display options
             $mform->set_data($displayoptions +compact('detailedmarks', 'pagesize'));
For the overview report : MDL-<I> "Option to only show / export final grade" and MDL-<I> "Make it clear which student attempt gives the final grade, if the scoring method is first, last or highest score" fixed a small problem I noticed in this patch.