# how to quit the psychtoolbox script without killing matlab

**URL:** <https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939>\
**Category:** Uncategorized\
**Created:** [February 27, 2006, 2:02am UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939 "2006-02-27T02:02:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [February 27, 2006, 2:02am UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939/1 "2006-02-27T02:02:35Z")

</div>

Hello

&nbsp;

I use psychtoolbox on windows operating systems

I would be glad to find a way to kill psychtoolbox script in the middle of its running, without killing matlab&nbsp;using&nbsp;task manager

I know at Mac OS it is possible using apple dot controls

&nbsp;

Regards 

Paleria Roman

---

<div class="post-metadata">

**Author:** ![greymatter\_24](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@greymatter\_24](https://psychtoolbox.discourse.group/u/greymatter_24)\
**Post date:** [February 27, 2006, 5:32am UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939/2 "2006-02-27T05:32:04Z")

</div>

Hi Paleria,

&nbsp;

This sometimes works, but not always (not sure why):

&nbsp;

Open another window along with the command window (the editor window usually works)

If MATLAB crashes, press CTRL-C to navigate to the editor window (this should close the Psychtoolbox screen)

Minimize this window and you should be able to click into the command window

Type Screen(‘CloseAll’) to close the psychtoolbox screen

&nbsp;

I’m definitely sure that this method will not work if the program is stuck in a “while KbCheck; end” loop.&nbsp; The only way I’ve found to get out of that is to use task manager and close MATLAB.&nbsp; I don’t know if there are any other cases where this method does not work.

Hope that helps,

Dan Little

&nbsp;

 
* * *
 

**From:** psychtoolbox@yahoogroups.com [mailto: psychtoolbox@yahoogroups.com] **On Behalf Of** paleria roman  
 **Sent:** Monday, February 27, 2006 10:03 AM  
 **To:** psychtoolbox@yahoogroups.com  
 **Subject:** [psychtoolbox] how to quit the psychtoolbox script without killing matlab

&nbsp;

Hello

&nbsp;

I use psychtoolbox on windows operating systems

I would be glad to find a way to kill psychtoolbox script in the middle of its running, without killing matlab&nbsp;using&nbsp;task manager

I know at Mac OS it is possible using apple dot controls

&nbsp;

Regards

Paleria Roman

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [February 27, 2006, 4:10pm UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939/3 "2006-02-27T16:10:31Z")

</div>

Hi Paleria,  
  
I poll for an "escape" keypress once on each trial, and if it's   
detected I close all screens and break out of the loop. The polling   
takes a minimum amount of time, and most times I have to do it anyway   
to record subject responses. The code is below.  
cheers  
johannes  
  
[keyIsDown, keysecs, keyCode] = KbCheck;  
if keyCode(KBName('escape'))  
 SCREEN('CloseAll');  
 break;  
end  
  
  
  

> On Feb 27, 2006, at 7:08 AM, Jeroen S. Benjamins wrote:  
>    
> \> Hi Paleria,  
> \>  
> \> what also works, even if your code has produced an  
> \> error, is hitting the Windows-key and after that  
> \> select the MATLAB command window again and typing  
> \> 'screen closeall'. In my experinece CTRL+C does stop  
> \> MATLAB, but it does not necessarily break you out of a  
> \> PTB screen. By hitting the windows-key MATLAB loses  
> \> focus, after which you can select the MATLAB window  
> \> you want to use again (that is, you can select the  
> \> command window again) and then close any PTB screen.  
> \> Still, there are instances where you will need to kill  
> \> MATLAB with the task manger wen you're stuck in a PTB  
> \> routine (e.g. when you've blocked your keyboard during  
> \> a stimulus presentation or something like that).  
> \>  
> \>  
> \> Regards  
> \> Jeroen Benjamins  
> \>  
> \>  
> \>  
> \> Jeroen Benjamins - A.B.C.-straat 10 bis - 3512 PX Utrecht  
> \> Tel. 030-2311385 Mob. 06-44292537  
> \> Mail: [mail@...](mailto:mail@...) / [j.s.benjamins@...](mailto:j.s.benjamins@...)  
> \> URL: [http://www.jsbenjamins.nl](http://www.jsbenjamins.nl)  
> \> =====================================  
> \> People like you and I, though mortal of course like  
> \> everyone else, do not grow old no matter how long  
> \> we live...[We] never cease to stand like curious  
> \> children before the great mystery into which we  
> \> were born.  
> \>  
> \> - Albert Einstein -  
> \> =====================================  
> \>  
> \>  
> \>  
> \>  
> \>  
> \>   
> \>   
> \>   
> \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> \> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide   
> \> with voicemail [http://uk.messenger.yahoo.com](http://uk.messenger.yahoo.com)  
> \>  
> \>  
> \> Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> \> Please indicate OS9, OSX, or WIN version, and include your full name.  
> \> Denis Pelli, David Brainard, and Allen Ingling.  
> \> [http://psychtoolbox.org](http://psychtoolbox.org)  
> \>  
> \> Yahoo! Groups Links  
> \>  
> \>  
> \>  
> \>  
> \>

---

<div class="post-metadata">

**Author:** ![daniel0906](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@daniel0906](https://psychtoolbox.discourse.group/u/daniel0906)\
**Post date:** [February 27, 2006, 7:40pm UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939/4 "2006-02-27T19:40:48Z")

</div>

Maybe this does not always work if intense code is looping or processing, but in simple situations of when the program hits an error, I seems to be able to just:

&nbsp;

1.&nbsp; Alt-Tab over to the MATLAB command window (and thereby hiding/minimizing the Psychtoolbox Screen.)

2.&nbsp; Type "clear screen" at the command prompt.  
&nbsp;

Daniel Shima

Vanderbilt Vision Research Center

  
&nbsp;

> On 2/27/06, **Johannes Haushofer** \<[haushof@...](mailto:haushof@...)\> wrote:
> 
> > Hi Paleria,  
> >   
> > I poll for an "escape" keypress once on each trial, and if it's  
> > detected I close all screens and break out of the loop. The polling  
> > takes a minimum amount of time, and most times I have to do it anyway  
> > to record subject responses. The code is below.  
> > cheers  
> > johannes  
> >   
> > [keyIsDown, keysecs, keyCode] = KbCheck;  
> > if keyCode(KBName('escape'))  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SCREEN('CloseAll');  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;  
> > end  
> >   
> >   
> >   
> > On Feb 27, 2006, at 7:08 AM, Jeroen S. Benjamins wrote:  
> >   
> > \> Hi Paleria,  
> > \>  
> > \> what also works, even if your code has produced an  
> > \> error, is hitting the Windows-key and after that  
> > \> select the MATLAB command window again and typing  
> > \> 'screen closeall'.&nbsp;&nbsp;In my experinece CTRL+C does stop  
> > \> MATLAB, but it does not necessarily break you out of a  
> > \> PTB screen. By hitting the windows-key MATLAB loses  
> > \> focus, after which you can select the MATLAB window  
> > \> you want to use again (that is, you can select the  
> > \> command window again) and then close any PTB screen.  
> > \> Still, there are instances where you will need to kill  
> > \> MATLAB with the task manger wen you're stuck in a PTB  
> > \> routine (e.g. when you've blocked your keyboard during  
> > \> a stimulus presentation or something like that).  
> > \>  
> > \>  
> > \> Regards  
> > \> Jeroen Benjamins  
> > \>  
> > \>  
> > \>  
> > \> Jeroen Benjamins - A.B.C.-straat 10 bis - 3512 PX Utrecht  
> > \> Tel. 030-2311385 Mob. 06-44292537  
> > \> Mail: [mail@...](mailto:mail@...) / [j.s.benjamins@...](mailto:j.s.benjamins@...)  
> > \> URL: [http://www.jsbenjamins.nl](http://www.jsbenjamins.nl)  
> > \> =====================================  
> > \> People like you and I, though mortal of course like  
> > \> everyone else, do not grow old no matter how long  
> > \> we live...[We] never cease to stand like curious  
> > \> children before the great mystery into which we  
> > \> were born.  
> > \>  
> > \> - Albert Einstein -  
> > \> =====================================  
> > \>  
> > \>  
> > \>  
> > \>  
> > \>  
> > \>  
> > \>  
> > \>  
> > \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > \> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide  
> > \> with voicemail [http://uk.messenger.yahoo.com](http://uk.messenger.yahoo.com)  
> > \>  
> > \>  
> > \> Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> > \> Please indicate OS9, OSX, or WIN version, and include your full name.  
> > \> Denis Pelli, David Brainard, and Allen Ingling.  
> > \> [http://psychtoolbox.org](http://psychtoolbox.org)  
> > \>  
> > \> Yahoo! Groups Links  
> > \>  
> > \>  
> > \>  
> > \>  
> > \>  
> >   
> >   
> >   
> > Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> > Please indicate OS9, OSX, or WIN version, and include your full name.  
> > Denis Pelli, David Brainard, and Allen Ingling.  
> > [http://psychtoolbox.org](http://psychtoolbox.org)  
> >   
> > Yahoo! Groups Links  
> >   
> > \<\*\> To visit your group on the web, go to:  
> > &nbsp;&nbsp; [http://groups.yahoo.com/group/psychtoolbox/](http://groups.yahoo.com/group/psychtoolbox/)  
> >   
> > \<\*\> To unsubscribe from this group, send an email to:  
> > &nbsp;&nbsp; [psychtoolbox-unsubscribe@yahoogroups.com](mailto:psychtoolbox-unsubscribe@yahoogroups.com)  
> >   
> > \<\*\> Your use of Yahoo! Groups is subject to:  
> > &nbsp;&nbsp; [http://docs.yahoo.com/info/terms/](http://docs.yahoo.com/info/terms/)

---

<div class="post-metadata">

**Author:** ![greymatter\_24](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@greymatter\_24](https://psychtoolbox.discourse.group/u/greymatter_24)\
**Post date:** [February 28, 2006, 3:06am UTC](https://psychtoolbox.discourse.group/t/how-to-quit-the-psychtoolbox-script-without-killing-matlab/939/5 "2006-02-28T03:06:44Z")

</div>

Ah, my mistake.&nbsp; I should have written ALT-Tab instead of CTRL+C.

Thanks for picking that up.  
   
Dan

&nbsp;

 
* * *
 

**From:** psychtoolbox@yahoogroups.com [mailto:psychtoolbox@yahoogroups.com] **On Behalf Of** Jeroen S. Benjamins  
 **Sent:** Monday, February 27, 2006 8:08 PM  
 **To:** psychtoolbox@yahoogroups.com; rahidt@...  
 **Subject:** [psychtoolbox] Re: RE: how to quit the psychtoolbox script without killing matlab

&nbsp;

Hi Paleria,  
   
 what also works, even if your code has produced an  
 error, is hitting the Windows-key and after that  
 select the MATLAB command window again and typing  
 'screen closeall'.&nbsp; In my experinece CTRL+C does stop  
 MATLAB, but it does not necessarily break you out of a  
 PTB screen. By hitting the windows-key MATLAB loses  
 focus, after which you can select the MATLAB window  
 you want to use again (that is, you can select the  
 command window again) and then close any PTB screen.  
 Still, there are instances where you will need to kill  
 MATLAB with the task manger wen you're stuck in a PTB  
 routine (e.g. when you've blocked your keyboard during  
 a stimulus presentation or something like that).  
   
   
 Regards  
 Jeroen Benjamins  
   
   
   
 Jeroen Benjamins - A.B.C.-straat 10 bis - 3512 PX Utrecht   
 Tel. 030-2311385 Mob. 06-44292537   
 Mail: mail@... / j.s.benjamins@...   
 URL: [http://www.jsbenjamins.nl](http://www.jsbenjamins.nl)   
 =====================================   
 People like you and I, though mortal of course like   
 everyone else, do not grow old no matter how long   
 we live...[We] never cease to stand like curious   
 children before the great mystery into which we   
 were born.   
   
 - Albert Einstein -   
 =====================================  
   
   
   
 Hi Paleria,

&nbsp;

This sometimes works, but not always (not sure why):

&nbsp;

Open another window along with the command window (the editor window usually works)

If MATLAB crashes, press CTRL-C to navigate to the editor window (this should close the Psychtoolbox screen)

Minimize this window and you should be able to click into the command window

Type Screen(‘CloseAll’) to close the psychtoolbox screen

&nbsp;

I’m definitely sure that this method will not work if the program is stuck in a “while KbCheck; end” loop.&nbsp; The only way I’ve found to get out of that is to use task manager and close MATLAB.&nbsp; I don’t know if there are any other cases where this method does not work.

Hope that helps,

Dan Little

&nbsp;

 
* * *
 

**From:** psychtoolbox@yahoogroups.com [mailto: psychtoolbox@yahoogroups.com] **On Behalf Of** paleria roman  
 **Sent:** Monday, February 27, 2006 10:03 AM  
 **To:** psychtoolbox@yahoogroups.com  
 **Subject:** [psychtoolbox] how to quit the psychtoolbox script without killing matlab

&nbsp;

Hello

&nbsp;

I use psychtoolbox on windows operating systems

I would be glad to find a way to kill psychtoolbox script in the middle of its running, without killing matlab&nbsp;using&nbsp;task manager

I know at Mac OS it is possible using apple dot controls

&nbsp;

Regards

Paleria Roman
