Matlab R2020b freezes when closing figure (Intel macOS Big Sur)
Mostrar comentarios más antiguos
Matlab R2020b Update 3 always freezes when closing a figure window containing any axes by using the top left closing button.
The operating system I am using is macOS Big Sur 11.1 on an Intel Mac Book Pro from mid-2017. No startup scripts are run.
On my system this can always be reproduced by opening Matlab 2020b and run the following command from the command window
figure; plot(1:10,1:10)
The figure opens as expected but using the red close button on the top left corner to close the window, Matlab instantly freezes and a spinning ball animation is shown. Matlab must be force quit then.
There is no problem closing the figure using the command
close(gcf)
This bug makes working with Matlab completely impossible to me. A similar behaviour could be seen on my system with previous Matlab versions like R2020a on macOS Mojave. But back then the bug was not so easy to reproduce. From time to time when closing a window belonging to Matlab it also froze.
15 comentarios
Frederik Blang
el 18 de En. de 2021
I am having the exact same problem on two different machines both running macOS Catalina 10.15.7 and MATLAB R2020b Update 3. Closing any figure using the red close button makes MATLAB unresponsive and the only way to close it is to force quit. Using
close 1
or similar works however.
Moritz Kb
el 25 de Feb. de 2021
Same here. Maybe this will help.
https://de.mathworks.com/matlabcentral/answers/646743-matlab-2020b-crashes-everytime-i-close-a-figure-manually#answer_543643
Haven’t tried any of the solutions yet. But there are a handful of different tricks.
Annoying because working with GUI software is impossible atm.
Moritz Kb
el 25 de Feb. de 2021
Ah well done! AltTab will probably fix it for me as well then. Thanks for sharing.
orenams
el 3 de En. de 2022
Movida: Rena Berman
el 9 de En. de 2025
I have the same proboem!
Mario Andrés De los Santos
el 3 de En. de 2022
Movida: Rena Berman
el 9 de En. de 2025
I'm having the same problem :(
Hongfu Sun
el 24 de Feb. de 2022
absolutely ridiculous that MATLAB is not fixing this bug, for at least a couple of years. considering how much they charge for the software!
Carl Werner
el 21 de Mzo. de 2022
I have this exact problem with 2021b on latest Monterey
Same problem using 2022a and 2022b on different Macs: iMac 2021 M1 and Macbook Pro 2022 M2, both running OS-X 12.5 (Monterey). Any time I close a figure by pressing the red x button on the figure causes a freeze (hang) with the Mac beachball. Closing a figure using 'close' works sometimes, but sometimes also causes a freeze. I suspect a java problem. None of the suggestions below have helped resolve this problem.
After consulation with Mathworks, it turns out that, in my case, this occurred due to using Mac's Virtual Keyboard: "Using the Virtual Keyboard with MATLAB is not supported due to a known Java bug with accessibility."
Enrico Onofri
el 3 de Oct. de 2023
Unfortunately the same 'freezing after closing plots' occurs in the latest R2023b running under the most recent MacOs & Java software. This is quite annoying since I use Matlab in class and my programs are based on statistical visualizations. I'll try one of the workarounds.
Álvaro Martín Gorroño
el 5 de Dic. de 2023
Still ocurrs, any fix? Thanks
bader
el 20 de Dic. de 2023
I have the same problem on R2023b running on MacOs Sonoma with M1 chip. Contacting Matlab and waiting for response. Any fixes from others? I don't have grammarly and I disabled most apps in "Accessibility" but still have the problem.
Puneet Kumar Jain
el 15 de Feb. de 2024
I t worked for me. Many thanks
Respuestas (20)
bader
el 20 de Dic. de 2023
4 votos
Found something that worked based on an answer here : https://www.mathworks.com/matlabcentral/answers/1808195-matlab-r2022a-freezes-on-macos-monterey-12-5-1-when-closing-a-figure#answer_1324680
Make a startup.m file in your matlab path (e.g, User/username/Documents/MATLAB/). And have the following line of code:
set(groot, 'defaultFigureCloseRequestFcn', 'delete(gcf)');
5 comentarios
Stephane
el 21 de En. de 2024
Excellent !!
Filippo
el 23 de En. de 2024
Great!
David
el 10 de Feb. de 2024
Works, thank you.
nody
el 24 de Abr. de 2024
works for macbook air m2 chip thank you!!!💪
세주
el 11 de En. de 2025
Can't believe I finally fixed the issue with this simple line of code. Thanks! I'm using MBP 2019 16" with i9 processor.
Kazuhiro Maeda
el 29 de En. de 2022
I wrote a simple script. I hope it helps. I'm not sure this works for M1.
function figure_close_test()
% When you try to close figure windows, MATLAB for Mac sometimes gives you
% the rainbow cursor of death and hangs up. A walkaround is to turn off
% apps that use Mac's Accessibility API. Go to System Preferences >
% Security & Privacy > Privacy > Accessibility and unmark some apps there.
%
% This script is helpful to identify the apps that cause the problem.
%
% (1) Run this script. If it finishes without any problems, you don't have
% the "can't close a figure" issue. Lucky you! If your MATLAB hangs up
% or becomes sluggish, go to (2).
%
% (2) Turn off an app shown in Accessibility and go to (3).
%
% (3) Run this script again. If you finished it without any problems, then
% it is likely that the app you just turned off interferes with MATLAB.
% So, it should be turned off while you use MATLAB (and ask MathWorks
% to fix this long-standing issue). If you got some problems while
% running this script, go back to (2) and turn off another app.
clear all;
close all;
for i = 1 : 10
fprintf('%d: ',i)
for j = 1 : 10
fprintf('%d ',j)
figure;
plot([0,1,2],[0,1,2])
end
close all;
fprintf('--- All figures closed\n')
end
In my case, RescueTime was the one that prevented MATLAB from closing a figure window.
6 comentarios
Vani Gupta
el 29 de En. de 2022
Editada: Vani Gupta
el 29 de En. de 2022
Thanks a lot for this! It worked. I have Macbook M1 Air and for me it was Grammarly desktop.
David Snyder
el 6 de Mzo. de 2022
Thank you!. This worked for my iMac with Catalina and 2021b. Unfortunately the culprit was SteerMouse--a utility that modifies mouse and scroll wheel behavior. It's the only utility I've found that allows me to properly use KiCAD and FreeCAD.
Linjun He
el 16 de Nov. de 2022
You saved my day!!!! Surprisingly it is Bartender causing this issue!!!
俊彦
el 19 de Feb. de 2023
Thank you so much! For me it is Contexts causing this issue.
Jack Addie
el 11 de Nov. de 2023
this worked brilliantly on my M1 2020 mac. Running R2022b incase thats of any use ot anyone. Cheers!
RossMas
el 7 de Feb. de 2024
Hi, could you please explain better all passages? I went to Accessibility, but did no find any apps to unmark. Thank you
Lakshmanan Swaminathan
el 17 de Mayo de 2021
2 votos
I do have the same problem with Matlab_R2020b running on M1 Macbook Pro with macOS Big Sur 11.3.1. Not just closing figures, it freezes in many occasions. And the only way is to force quit and reopen again leading to lose the progress of work.
Radoslav Vargic
el 28 de Jun. de 2021
2 votos
Matlab 2021a update 3 in BigSur 11.4 has stiil the same problem !!!
5 comentarios
Margarethe Leopold
el 1 de Jul. de 2021
Yes, I am also seriously frustrated right now. I need to force quite Matlab every third run of my scripts now. I mostly occurs when I press any key or when I click into the code editor while a figure is still being processed. Can we please finally get an official note on this bug by Mathworks and a proper timelime when it is expected to be fixes. I am spaming Apple with 10-15 crash reports per day now.
Walter Roberson
el 1 de Jul. de 2021
Mathworks has a bug report that says that some Big Sur crashes can be avoided by starting MATLAB from the Terminal instead of from Dock or icon.
Kelly Kearney
el 1 de Jul. de 2021
For the record, this figure-closing problem is not specific to Big Sur; I encounter it regularly with Matlab R2020b and I'm still using Mojave. My not particularly great solution has been to roll back to 2019a (the previous version I had installed) for the time being.
Walter Roberson
el 2 de Jul. de 2021
Odd, I have never observed it up to R2021a up to Catalina (I have not used my Big Sur system long enough to have an opinion)
Kelly Kearney
el 15 de Jul. de 2021
The bug is contingent on other software, so it may not manifest for all users. I'm pretty sure that in my case, it's coming from one of the many videoconferencing apps that I'm using far more these days than in previous years. Keeping those apps functional is a higher priority than running the latest and greatest Matlab, hence my rolling back.
Chenyang Zhang
el 24 de Mzo. de 2022
2 votos
Go to Mac - System Preferences - Privacy - Accessibility
Try disabling some App here, and find which one cause the conflict to MATLAB. Then this problem can be avoided. As for my case, I disable the Grammarly and then all things go well.
Hope MATLAB can solve this problem.
3 comentarios
Preetham Manjunatha
el 24 de Mzo. de 2022
Yes, I confirm the culprit is Grammarly.
Zhaocheng Wang
el 24 de Mzo. de 2022
I comfirm the culprit is Grammarly as well.
Nathaniel
el 27 de Dic. de 2024
For me the culprit was Wispr Flow
Daniel Lau
el 20 de Jul. de 2021
1 voto
From this link, I followed the instructions for giving Matlab full disk access. Seems to have solved the problem.
2 comentarios
Bojeong Seo
el 25 de Mzo. de 2022
Unfortunately I did this but, it didn't solve my issue yet..
Bo Liu
el 25 de Ag. de 2022
It didn't work for me, either.
Pistachio
el 21 de Jul. de 2022
Editada: Walter Roberson
el 17 de Nov. de 2022
Same problem for me.
In my case, MATLAB often freezes when closing a number of heavy figures.
The cause of this problem is most probably that MATLAB goes on the next closing process before completing current closing process that takes some time due to the large data set included in the figures. In this case, close each figure by “for” followed by a command such as “disp” and “waitbar”. But “1+1” doesn't work. Though “pause(n)” does work, I don't recommend this, because optimum time is not known. I prefer “waitbar” to “disp” because I don't like a mess in command window, but “waitbar” can be replaced by “disp” or something. Accordingly, I solved this issue by following function.
function closeall
h = findobj('Type','Figure');
I0 = numel(h);
if I0==0
return
elseif I0==1
close(h)
else
msg = ['Closing ' num2str(I0) ' figures.'];
f = waitbar(0,msg);
for i0 = 1:I0
close(h(i0))
waitbar(i0/I0,f, ['Closing ' num2str(I0) ' figures... (' num2str(i0) '/' num2str(I0) ')'])
end
delete(f)
end
end
2 comentarios
Dirk
el 8 de En. de 2025
I thought I'd tried everything over the past year or more and this is the first work-around that actually seems to consistently work. Thank you!
R2024b
Apple M3 Sonoma 14.7.1 (agency controlled)
Java 11.0.25+9-LTS with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
No apps in Settings>Privacy & Security>Accessibility selected
Dirk
el 9 de En. de 2025
The other thing I had tried to no avail was the startup.m script in Users/User/Documents/MATLAB containing
set(groot, 'defaultFigureCloseRequestFcn', 'delete(gcf)');
Abdul Hannan Raja
el 23 de Abr. de 2021
0 votos
I am having this same problem on M1 Macbook Air with apple silicon chip. I have no idea what is causing this issue. I guess i am not alone anymore.
3 comentarios
jiayi su
el 3 de Ag. de 2021
Yes, you are not alone.
Peko Wang
el 14 de Feb. de 2022
You are not alone. I have the same problem with my M1 Mac Mini; this post is helpful for me. Specifically, there is a bug caused by some conflict between the Grammarly app and Matlab, but every time you manually close the fig, you need to quit Grammarly, and setting Grammarly not enabled on Matlab is also invalid, which is very inconvenient, so I still use the "close" command.
Bojeong Seo
el 25 de Mzo. de 2022
@Peko Wang Thank you so much!! I was frastrauted by this issue and just solve the issue by quitting Grammarly app!!
Tahmid Hassan Talukdar
el 27 de Mayo de 2021
0 votos
Havint this same problem. Hope MathWorks fixes this soon. I'm unable to do any work due to this.
Dmitry Kabanov
el 15 de Jul. de 2021
0 votos
I have the same problem on macos Big Sur 11.4 with Matlab R2021a 9.10.0.1602886 on Intel iMac Pro 2017.
Matlab is unusable as it hangs when I close a figure.
Daniel Lau
el 20 de Jul. de 2021
0 votos
I am having this problem too on an Intel Mac Pro 2013 with Matlab R2021a.
Preetham Manjunatha
el 23 de En. de 2022
Editada: Preetham Manjunatha
el 23 de En. de 2022
0 votos
Same problem macOS Monterey v12.1. MacBook Pro (15-inch, 2018), Processor: 2.9 GHz 6-Core Intel Core i9 and Memory: 32 GB 2400 MHz DDR4.
2 comentarios
Mario Andrés De los Santos
el 23 de En. de 2022
This means that is not an Apple silicon issue, is a MacOs compatibility problem
Preetham Manjunatha
el 24 de En. de 2022
Yes, I think so. It is macOS and MATLAB compatability issue.
Kazuhiro Maeda
el 28 de En. de 2022
0 votos
Same here.
MATLAB R2021a
Big Sur 11.6.1
Mac Pro (2019)
After "close all" or clicking the left-top red "x" button of a figure window, a rainbow cursor of death appears and MATLAB hangs up. This happens not always but occasionally. So, it's difficult to find why this happens.
I just read this post and turned off Accessibility Permissions for some apps. I hope this will work. This "Accecibility problem" has been around for years (like this), and I don't understand why MathWorks devs don't fix it.
I think MathWorks should implement a better bug report program (or even telemetery program). If MATLAB hangs up, the bug report dialog doesn't appear. So, they never notice this issue.
Edgar Torres
el 7 de Feb. de 2022
0 votos
My Macbook Pro (2019, Intel, Big Sur v.11.6.3) suffers from this issue as well, the "close all" command does work though. Although granting Matlab full disk access to your mac will not work, I already tried it. @MathWorks Support Team really needs to fix this.
2 comentarios
Hao Chen
el 15 de Feb. de 2022
Do you use Grammarly? After I close Grammarly, it's fixed!
Edgar Torres
el 15 de Feb. de 2022
oh really? I haven't thought of that, will try it then.
Richard So
el 20 de Feb. de 2022
Editada: Richard So
el 20 de Feb. de 2022
0 votos
I found that downgrading to R2019b resolves the issue. Alt-Tab was the culprit on my end, but I was not willing to close the app just for Matlab. If downgrading still does not help, try using even earlier versions and see if it works.
Preetham Manjunatha
el 19 de Mzo. de 2022
0 votos
MATLAB R2022a still freezes when the Figure window is closed on macOS 12.3.
Nazyar Mehdishishavan
el 30 de Mzo. de 2022
0 votos
just by quiting grammerly, my problem was solved
1 comentario
Guillermo Romero
el 28 de Jun. de 2022
The same here
Carl Werner
el 31 de Mzo. de 2022
0 votos
Yes - Grammarly and my window manager app, Rectangle make Matlab lose its mind. The window manager Magnet, also does not coexist well with Matlab.
Qi Wang
el 6 de Mayo de 2022
0 votos
Same issue for me. Problem solved after I disable the "voice control" in the System Preferences. Hope this helps
Sorinel Oprisan
el 3 de Jun. de 2022
0 votos
For me it was Grammarly Desktop.app
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!