On Windows, how can I gracefully ask a running program to terminate?












12















On Unix or Linux, it's easy to gracefully ask a running application to terminate: you send it the SIGTERM signal. If its process ID is 1234, you can simply run kill 1234 or kill -s TERM 1234 or kill -15 1234.



How can I do the same thing in Windows?



If I recall correctly, Task Manager's "End Task" feature (not its "End Process" feature) used to do what I want. But, as of Windows 8.1, it's no longer so gentle; when I use the feature, it causes me to lose unsaved data.



I don't want to write any code in order to do this. If I did, I would ask on Stack Overflow. :)










share|improve this question




















  • 1





    If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

    – unforgettableid
    Aug 19 '15 at 2:15






  • 4





    There is nothing graceful about Windows........

    – Moab
    Aug 19 '15 at 14:59
















12















On Unix or Linux, it's easy to gracefully ask a running application to terminate: you send it the SIGTERM signal. If its process ID is 1234, you can simply run kill 1234 or kill -s TERM 1234 or kill -15 1234.



How can I do the same thing in Windows?



If I recall correctly, Task Manager's "End Task" feature (not its "End Process" feature) used to do what I want. But, as of Windows 8.1, it's no longer so gentle; when I use the feature, it causes me to lose unsaved data.



I don't want to write any code in order to do this. If I did, I would ask on Stack Overflow. :)










share|improve this question




















  • 1





    If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

    – unforgettableid
    Aug 19 '15 at 2:15






  • 4





    There is nothing graceful about Windows........

    – Moab
    Aug 19 '15 at 14:59














12












12








12


1






On Unix or Linux, it's easy to gracefully ask a running application to terminate: you send it the SIGTERM signal. If its process ID is 1234, you can simply run kill 1234 or kill -s TERM 1234 or kill -15 1234.



How can I do the same thing in Windows?



If I recall correctly, Task Manager's "End Task" feature (not its "End Process" feature) used to do what I want. But, as of Windows 8.1, it's no longer so gentle; when I use the feature, it causes me to lose unsaved data.



I don't want to write any code in order to do this. If I did, I would ask on Stack Overflow. :)










share|improve this question
















On Unix or Linux, it's easy to gracefully ask a running application to terminate: you send it the SIGTERM signal. If its process ID is 1234, you can simply run kill 1234 or kill -s TERM 1234 or kill -15 1234.



How can I do the same thing in Windows?



If I recall correctly, Task Manager's "End Task" feature (not its "End Process" feature) used to do what I want. But, as of Windows 8.1, it's no longer so gentle; when I use the feature, it causes me to lose unsaved data.



I don't want to write any code in order to do this. If I did, I would ask on Stack Overflow. :)







windows process task-manager kill exit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 28 '17 at 2:24







unforgettableid

















asked Aug 19 '15 at 2:09









unforgettableidunforgettableid

6532926




6532926








  • 1





    If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

    – unforgettableid
    Aug 19 '15 at 2:15






  • 4





    There is nothing graceful about Windows........

    – Moab
    Aug 19 '15 at 14:59














  • 1





    If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

    – unforgettableid
    Aug 19 '15 at 2:15






  • 4





    There is nothing graceful about Windows........

    – Moab
    Aug 19 '15 at 14:59








1




1





If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

– unforgettableid
Aug 19 '15 at 2:15





If you're a software developer, and you want to do this programmatically, see the related Stack Overflow question on how to gracefully ask a process to terminate.

– unforgettableid
Aug 19 '15 at 2:15




4




4





There is nothing graceful about Windows........

– Moab
Aug 19 '15 at 14:59





There is nothing graceful about Windows........

– Moab
Aug 19 '15 at 14:59










3 Answers
3






active

oldest

votes


















14














taskkill.exe



Andy E writes that you can use taskkill.exe.



To terminate the process with process ID 1234:



taskkill /pid 1234


To terminate notepad.exe:



taskkill /im notepad.exe


For more help:



taskkill /?


He adds:




The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.




He's right. I tried using taskkill.exe (without /f) to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



I'm using the home version of Windows 8.1. It looks like taskkill.exe came included with Windows at no extra charge. It's in c:windowssystem32.



Or just log out



If you don't want to bother with any of this, simply log out of your Windows user account, then log back in again.



Console applications



Regarding console applications (e.g. PowerShell), Chris Becke adds:




There is no real way to close console applications gracefully on Windows. They need to support some kind of graceful close mechanism.







share|improve this answer


























  • Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

    – Matt McHenry
    Jan 28 '16 at 21:54



















4














You can use rmlogotest.exe (the Restart Manager Logo Test Tool). This freeware utility, written by Microsoft, is part of the Windows App Certification Kit.



To get the latest version of the Windows App Certification Kit, download and run the Windows SDK installer. (You can find the latest Windows SDK installer by doing a Google search.) Uncheck all the boxes except for the Windows App Certification Kit box. Wait for the kit to be downloaded and installed. If I recall correctly, the kit is a couple hundred megabytes.



rmlogotest.exe will probably be in C:Program Files (x86)Windows Kits10App Certification Kit if you're using version 10 of the Windows SDK.



Open a command prompt. Change to the correct directory. Enter rmlogotest then a space then the process's process ID number.



If the process is "Restart Manager aware", rmlogotest will gracefully restart it and tell you "Logo Validation Passed". Otherwise, rmlogotest will ask it to gracefully terminate, then may tell you "Logo Validation Failed".



I tried using rmlogotest.exe to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



(In case you wonder what Restart Manager is and does, let me explain. Restart Manager is part of Windows, and is used by Windows Installer 4.0 and up. When Windows Installer needs to overwrite or delete an open file, it uses a three-step process. It tells Restart Manager to gracefully end the process which is using the file. It overwrites the file. Then it tells Restart Manager to start the process again.)






share|improve this answer

































    0














    GnuWIN32 has windows ports of common linux utils including kill.exe



    http://gnuwin32.sourceforge.net/



    It supports the following signals by name, or a number



    λ kill -l                                                                                                                                                                                                                                                                
    INT
    ILL
    FPE
    KILL
    SEGV
    TERM
    CHLD
    ABRT





    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f959364%2fon-windows-how-can-i-gracefully-ask-a-running-program-to-terminate%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      14














      taskkill.exe



      Andy E writes that you can use taskkill.exe.



      To terminate the process with process ID 1234:



      taskkill /pid 1234


      To terminate notepad.exe:



      taskkill /im notepad.exe


      For more help:



      taskkill /?


      He adds:




      The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.




      He's right. I tried using taskkill.exe (without /f) to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



      I'm using the home version of Windows 8.1. It looks like taskkill.exe came included with Windows at no extra charge. It's in c:windowssystem32.



      Or just log out



      If you don't want to bother with any of this, simply log out of your Windows user account, then log back in again.



      Console applications



      Regarding console applications (e.g. PowerShell), Chris Becke adds:




      There is no real way to close console applications gracefully on Windows. They need to support some kind of graceful close mechanism.







      share|improve this answer


























      • Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

        – Matt McHenry
        Jan 28 '16 at 21:54
















      14














      taskkill.exe



      Andy E writes that you can use taskkill.exe.



      To terminate the process with process ID 1234:



      taskkill /pid 1234


      To terminate notepad.exe:



      taskkill /im notepad.exe


      For more help:



      taskkill /?


      He adds:




      The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.




      He's right. I tried using taskkill.exe (without /f) to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



      I'm using the home version of Windows 8.1. It looks like taskkill.exe came included with Windows at no extra charge. It's in c:windowssystem32.



      Or just log out



      If you don't want to bother with any of this, simply log out of your Windows user account, then log back in again.



      Console applications



      Regarding console applications (e.g. PowerShell), Chris Becke adds:




      There is no real way to close console applications gracefully on Windows. They need to support some kind of graceful close mechanism.







      share|improve this answer


























      • Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

        – Matt McHenry
        Jan 28 '16 at 21:54














      14












      14








      14







      taskkill.exe



      Andy E writes that you can use taskkill.exe.



      To terminate the process with process ID 1234:



      taskkill /pid 1234


      To terminate notepad.exe:



      taskkill /im notepad.exe


      For more help:



      taskkill /?


      He adds:




      The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.




      He's right. I tried using taskkill.exe (without /f) to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



      I'm using the home version of Windows 8.1. It looks like taskkill.exe came included with Windows at no extra charge. It's in c:windowssystem32.



      Or just log out



      If you don't want to bother with any of this, simply log out of your Windows user account, then log back in again.



      Console applications



      Regarding console applications (e.g. PowerShell), Chris Becke adds:




      There is no real way to close console applications gracefully on Windows. They need to support some kind of graceful close mechanism.







      share|improve this answer















      taskkill.exe



      Andy E writes that you can use taskkill.exe.



      To terminate the process with process ID 1234:



      taskkill /pid 1234


      To terminate notepad.exe:



      taskkill /im notepad.exe


      For more help:



      taskkill /?


      He adds:




      The /f switch would force the kill, but not using it just sends the termination signal so the application closes gracefully.




      He's right. I tried using taskkill.exe (without /f) to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



      I'm using the home version of Windows 8.1. It looks like taskkill.exe came included with Windows at no extra charge. It's in c:windowssystem32.



      Or just log out



      If you don't want to bother with any of this, simply log out of your Windows user account, then log back in again.



      Console applications



      Regarding console applications (e.g. PowerShell), Chris Becke adds:




      There is no real way to close console applications gracefully on Windows. They need to support some kind of graceful close mechanism.








      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Sep 1 '17 at 16:48


























      community wiki





      7 revs
      unforgettableid














      • Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

        – Matt McHenry
        Jan 28 '16 at 21:54



















      • Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

        – Matt McHenry
        Jan 28 '16 at 21:54

















      Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

      – Matt McHenry
      Jan 28 '16 at 21:54





      Note that this does not exactly replicate what happens on logout or shutdown; for that, see stackoverflow.com/questions/520910/…

      – Matt McHenry
      Jan 28 '16 at 21:54













      4














      You can use rmlogotest.exe (the Restart Manager Logo Test Tool). This freeware utility, written by Microsoft, is part of the Windows App Certification Kit.



      To get the latest version of the Windows App Certification Kit, download and run the Windows SDK installer. (You can find the latest Windows SDK installer by doing a Google search.) Uncheck all the boxes except for the Windows App Certification Kit box. Wait for the kit to be downloaded and installed. If I recall correctly, the kit is a couple hundred megabytes.



      rmlogotest.exe will probably be in C:Program Files (x86)Windows Kits10App Certification Kit if you're using version 10 of the Windows SDK.



      Open a command prompt. Change to the correct directory. Enter rmlogotest then a space then the process's process ID number.



      If the process is "Restart Manager aware", rmlogotest will gracefully restart it and tell you "Logo Validation Passed". Otherwise, rmlogotest will ask it to gracefully terminate, then may tell you "Logo Validation Failed".



      I tried using rmlogotest.exe to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



      (In case you wonder what Restart Manager is and does, let me explain. Restart Manager is part of Windows, and is used by Windows Installer 4.0 and up. When Windows Installer needs to overwrite or delete an open file, it uses a three-step process. It tells Restart Manager to gracefully end the process which is using the file. It overwrites the file. Then it tells Restart Manager to start the process again.)






      share|improve this answer






























        4














        You can use rmlogotest.exe (the Restart Manager Logo Test Tool). This freeware utility, written by Microsoft, is part of the Windows App Certification Kit.



        To get the latest version of the Windows App Certification Kit, download and run the Windows SDK installer. (You can find the latest Windows SDK installer by doing a Google search.) Uncheck all the boxes except for the Windows App Certification Kit box. Wait for the kit to be downloaded and installed. If I recall correctly, the kit is a couple hundred megabytes.



        rmlogotest.exe will probably be in C:Program Files (x86)Windows Kits10App Certification Kit if you're using version 10 of the Windows SDK.



        Open a command prompt. Change to the correct directory. Enter rmlogotest then a space then the process's process ID number.



        If the process is "Restart Manager aware", rmlogotest will gracefully restart it and tell you "Logo Validation Passed". Otherwise, rmlogotest will ask it to gracefully terminate, then may tell you "Logo Validation Failed".



        I tried using rmlogotest.exe to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



        (In case you wonder what Restart Manager is and does, let me explain. Restart Manager is part of Windows, and is used by Windows Installer 4.0 and up. When Windows Installer needs to overwrite or delete an open file, it uses a three-step process. It tells Restart Manager to gracefully end the process which is using the file. It overwrites the file. Then it tells Restart Manager to start the process again.)






        share|improve this answer




























          4












          4








          4







          You can use rmlogotest.exe (the Restart Manager Logo Test Tool). This freeware utility, written by Microsoft, is part of the Windows App Certification Kit.



          To get the latest version of the Windows App Certification Kit, download and run the Windows SDK installer. (You can find the latest Windows SDK installer by doing a Google search.) Uncheck all the boxes except for the Windows App Certification Kit box. Wait for the kit to be downloaded and installed. If I recall correctly, the kit is a couple hundred megabytes.



          rmlogotest.exe will probably be in C:Program Files (x86)Windows Kits10App Certification Kit if you're using version 10 of the Windows SDK.



          Open a command prompt. Change to the correct directory. Enter rmlogotest then a space then the process's process ID number.



          If the process is "Restart Manager aware", rmlogotest will gracefully restart it and tell you "Logo Validation Passed". Otherwise, rmlogotest will ask it to gracefully terminate, then may tell you "Logo Validation Failed".



          I tried using rmlogotest.exe to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



          (In case you wonder what Restart Manager is and does, let me explain. Restart Manager is part of Windows, and is used by Windows Installer 4.0 and up. When Windows Installer needs to overwrite or delete an open file, it uses a three-step process. It tells Restart Manager to gracefully end the process which is using the file. It overwrites the file. Then it tells Restart Manager to start the process again.)






          share|improve this answer















          You can use rmlogotest.exe (the Restart Manager Logo Test Tool). This freeware utility, written by Microsoft, is part of the Windows App Certification Kit.



          To get the latest version of the Windows App Certification Kit, download and run the Windows SDK installer. (You can find the latest Windows SDK installer by doing a Google search.) Uncheck all the boxes except for the Windows App Certification Kit box. Wait for the kit to be downloaded and installed. If I recall correctly, the kit is a couple hundred megabytes.



          rmlogotest.exe will probably be in C:Program Files (x86)Windows Kits10App Certification Kit if you're using version 10 of the Windows SDK.



          Open a command prompt. Change to the correct directory. Enter rmlogotest then a space then the process's process ID number.



          If the process is "Restart Manager aware", rmlogotest will gracefully restart it and tell you "Logo Validation Passed". Otherwise, rmlogotest will ask it to gracefully terminate, then may tell you "Logo Validation Failed".



          I tried using rmlogotest.exe to terminate Notepad, and it worked as expected. Notepad asked me whether or not I wanted to save the unsaved text which I'd entered.



          (In case you wonder what Restart Manager is and does, let me explain. Restart Manager is part of Windows, and is used by Windows Installer 4.0 and up. When Windows Installer needs to overwrite or delete an open file, it uses a three-step process. It tells Restart Manager to gracefully end the process which is using the file. It overwrites the file. Then it tells Restart Manager to start the process again.)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 28 '17 at 2:25

























          answered Dec 7 '16 at 18:18









          unforgettableidunforgettableid

          6532926




          6532926























              0














              GnuWIN32 has windows ports of common linux utils including kill.exe



              http://gnuwin32.sourceforge.net/



              It supports the following signals by name, or a number



              λ kill -l                                                                                                                                                                                                                                                                
              INT
              ILL
              FPE
              KILL
              SEGV
              TERM
              CHLD
              ABRT





              share|improve this answer




























                0














                GnuWIN32 has windows ports of common linux utils including kill.exe



                http://gnuwin32.sourceforge.net/



                It supports the following signals by name, or a number



                λ kill -l                                                                                                                                                                                                                                                                
                INT
                ILL
                FPE
                KILL
                SEGV
                TERM
                CHLD
                ABRT





                share|improve this answer


























                  0












                  0








                  0







                  GnuWIN32 has windows ports of common linux utils including kill.exe



                  http://gnuwin32.sourceforge.net/



                  It supports the following signals by name, or a number



                  λ kill -l                                                                                                                                                                                                                                                                
                  INT
                  ILL
                  FPE
                  KILL
                  SEGV
                  TERM
                  CHLD
                  ABRT





                  share|improve this answer













                  GnuWIN32 has windows ports of common linux utils including kill.exe



                  http://gnuwin32.sourceforge.net/



                  It supports the following signals by name, or a number



                  λ kill -l                                                                                                                                                                                                                                                                
                  INT
                  ILL
                  FPE
                  KILL
                  SEGV
                  TERM
                  CHLD
                  ABRT






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 11 at 11:05









                  teknopaulteknopaul

                  20828




                  20828






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f959364%2fon-windows-how-can-i-gracefully-ask-a-running-program-to-terminate%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown