diff --git a/matlab/+mom/run.m b/matlab/+mom/run.m
index 9c8607510d1b7512b5d109ccbc484701105832ed..370d46ffbbe9608f16e7f4eb7d83f66206fcc46a 100644
--- a/matlab/+mom/run.m
+++ b/matlab/+mom/run.m
@@ -1007,3 +1007,10 @@ if isoctave
 else
     warning on
 end
+
+if isoctave && isfield(options_, 'prior_restrictions') && ...
+   isfield(options_.prior_restrictions, 'routine')
+    % Octave crashes if it tries to save function handles (to the _results.mat file)
+    % See https://savannah.gnu.org/bugs/?43215
+    options_.prior_restrictions.routine = [];
+end
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index a790d8a87c3a4ec0b13704982802313a1416994d..51287f6c2127230a0f69e22d8882f03a3eeca291 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -229,3 +229,9 @@ options_.mode_file = mode_file0;
 %reset stored mode-file to user defined one (and in case it was only set by the recursive estimation)
 oo_.gui.ran_estimation = true;
 
+if isoctave && isfield(options_, 'prior_restrictions') && ...
+   isfield(options_.prior_restrictions, 'routine')
+    % Octave crashes if it tries to save function handles (to the _results.mat file)
+    % See https://savannah.gnu.org/bugs/?43215
+    options_.prior_restrictions.routine = [];
+end