quit doesn't close the program - process still running in task manager

104 views (last 30 days)
James
James on 28 Sep 2011
Answered: swathi anil on 24 Mar 2020
When I run the quit command in the command window or in a script, the application appears to close, but opening the Task Manager I find that there is still a process there taking up a large proportion of the CPU and memory named MATLAB.exe
It seems that it's still running in the background?
  4 Comments
James
James on 28 Sep 2011
It seems to be when a .m file being run calls others to run with run filename

Sign in to comment.

Accepted Answer

James
James on 29 Sep 2011
Splitting my script into two, with the first one handling a lot of code generation and ending with a quit, always worked fine. The second script ran tests, and ended with a quit, which has always worked fine.
Any integration of these scripts, either into a single script, or into a parent and child script (i.e. one invokes the other) caused problems with Matlab not closing properly.
It's very curious, but there must be some kind of interference between some commands that doesn't allow Matlab to close properly.
This isn't really a solution, but I'd posted the question in the hope someone knew how to force a close in some way, or perhaps had experience of the problem.
  2 Comments
James
James on 29 Sep 2011
I've had a go at something like that, but it's very inconsistent. The same script can be run multiple times and it won't always fail to close properly (sometimes it consistently works when run from within matlab, but consistently fails to close if it's run from the command line).
A bit hard to reduce to the problem code when it's tempermental.
Thanks though :)

Sign in to comment.

More Answers (3)

Daniel Shub
Daniel Shub on 28 Sep 2011
I am not sure what happens with MATLAB and rmdir if it fails to remove the directory (for example because of file permissions) it may cause MATLAB to hang. Really though you haven't given us enough to know what it happening. It is just going to be a painful line-by-line quit in between debug.
  1 Comment
James
James on 29 Sep 2011
rmdir is being used to remove a directory autogenerated by another command. Thanks for the suggestion, but it's always successful.

Sign in to comment.


Peter Barsznica
Peter Barsznica on 19 Jan 2016
  1 Comment
James
James on 20 Jan 2016
That is unrelated. This question is to do with a Matlab script that exits Matlab when it's done, yet Matlab continues to run.
Taskkill might work, although it seems like a bit of a brutal way to exit an application. It would take a bit more work if multiple instances of Matlab are running to ensure the correct one is killed.

Sign in to comment.


swathi anil
swathi anil on 24 Mar 2020
Hi James,
I was facing a similar problem, not being able to exit my matlab gui figures or even the matlab window at all.
Using
quit force
worked in this case. I would recommend going through the quit command variants in the following link, to pick the one that suits your scenario:
https://de.mathworks.com/help/matlab/ref/quit.html#d120e1010208

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!