How can I quit an app using Terminal?Can home and end keys be mapped when using Terminal?Bash Script that will start up second Terminal process?How do I kill a process that won't die?How do I programatically kill the CCLibrary process by PID?How does one start a bash command that doesn't close on Terminal quit?Quit terminal but store the session for next startHow to Programmatically Find, Kill, and Restart a local DynamoDB ProcessHow to switch focus to the app based on its PID from CLI?How to set a fixed title for a terminal in Mac?How can I open an app using Terminal?

Why is "Reports" in sentence down without "The"

If Manufacturer spice model and Datasheet give different values which should I use?

The use of multiple foreign keys on same column in SQL Server

How to make payment on the internet without leaving a money trail?

What typically incentivizes a professor to change jobs to a lower ranking university?

Why is an old chain unsafe?

Are there any consumables that function as addictive (psychedelic) drugs?

Can a German sentence have two subjects?

What would happen to a modern skyscraper if it rains micro blackholes?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Is there a familial term for apples and pears?

A Journey Through Space and Time

Draw simple lines in Inkscape

Copenhagen passport control - US citizen

How can bays and straits be determined in a procedurally generated map?

declaring a variable twice in IIFE

What would the Romans have called "sorcery"?

What are these boxed doors outside store fronts in New York?

Is Social Media Science Fiction?

I see my dog run

Japan - Plan around max visa duration

Could a US political party gain complete control over the government by removing checks & balances?

Email Account under attack (really) - anything I can do?

Can Medicine checks be used, with decent rolls, to completely mitigate the risk of death from ongoing damage?



How can I quit an app using Terminal?


Can home and end keys be mapped when using Terminal?Bash Script that will start up second Terminal process?How do I kill a process that won't die?How do I programatically kill the CCLibrary process by PID?How does one start a bash command that doesn't close on Terminal quit?Quit terminal but store the session for next startHow to Programmatically Find, Kill, and Restart a local DynamoDB ProcessHow to switch focus to the app based on its PID from CLI?How to set a fixed title for a terminal in Mac?How can I open an app using Terminal?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








20















I want to quit a certain applications on my Mac using Terminal. For example, how do I kill “Slack”? Do I need its PID number?










share|improve this question






























    20















    I want to quit a certain applications on my Mac using Terminal. For example, how do I kill “Slack”? Do I need its PID number?










    share|improve this question


























      20












      20








      20


      3






      I want to quit a certain applications on my Mac using Terminal. For example, how do I kill “Slack”? Do I need its PID number?










      share|improve this question
















      I want to quit a certain applications on my Mac using Terminal. For example, how do I kill “Slack”? Do I need its PID number?







      macos terminal command-line






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 29 at 1:23









      bmike

      161k46290629




      161k46290629










      asked Mar 27 at 14:15









      BrainmaniacBrainmaniac

      27718




      27718




















          5 Answers
          5






          active

          oldest

          votes


















          23














          No, you do not need to know its PID.



          You can use:



          pkill -x Slack


          Or:



          killall Slack



          Note: Be sure to read the manual page for whichever command you choose to use, in order to see the various options available to the command, as may be relevant to its particular usage. In Terminal type e.g. man pkill and press enter, or just type the command and right-click on it, then select: Open man Page






          share|improve this answer
































            17














            You can use AppleScript to tell the application to quit:



            osascript -e 'quit app "Slack"'


            this will tell the application to quit and will start all the save and cleanup tasks. Or you can send the TERM signal with pkill but it could be that the application will not shut down cleanly



            pkill -x Slack





            share|improve this answer




















            • 6





              This is the best method, because it replicates what happens when you use File>Quit from the menu.

              – Barmar
              Mar 28 at 16:15






            • 2





              Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

              – TJ Luoma
              Mar 30 at 2:58


















            12














            Since I don't yet have the reputation to comment, I'm saying this as a separate answer. pkill without any flags does not match a specific process! For example, running pkill foo would target processes named foo, but would also target processes named foobar. This is because it uses regular expressions.



            If you wish to kill a specific process, you can pass it the -x flag. For example, pkill -x foo. This will use exact names instead of regular expressions.



            For example, in your case, pkill -x Slack will do the trick.






            share|improve this answer

























            • To turn this into a full answer can you please add the name of the Slack process to kill?

              – nohillside
              Mar 29 at 16:48


















            8














            You can install htop (via brew for instance).



            You'll need to run this as root or with sudo. Essentially, it's a text
            based Activity Monitor.



            Select the process you want to kill (either with arrow keys or a mouse).



            Then press k to send the process a signal and then 9 to choose the SIGKILL signal.






            share|improve this answer















            We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.





















              6














              I'm not sure for Slack, but some Applications will run multiple Processes and you may want to kill just one (I find I often need to do this with iTunes, for example). In that case, you can run



              ps -e | grep -i slack


              To find all Processes with case-insensitive "slack" in the name. The output should look like (without the header):



              PID TTY TIME CMD
              649 pts/1 00:00:00 bash


              That first column will be your PID. You can then use that to kill specifically that process:



              kill -9 649


              Replacing 649 with your PID you found from calling ps.






              share|improve this answer


















              • 2





                kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                – Matteo
                Mar 28 at 17:58











              • Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                – Carl Witthoft
                Mar 29 at 14:59






              • 1





                @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                – user3439894
                Mar 29 at 22:26











              • So, pgrep is a nice command that combines ps and grip.

                – Harv
                Apr 3 at 0:47



















              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              23














              No, you do not need to know its PID.



              You can use:



              pkill -x Slack


              Or:



              killall Slack



              Note: Be sure to read the manual page for whichever command you choose to use, in order to see the various options available to the command, as may be relevant to its particular usage. In Terminal type e.g. man pkill and press enter, or just type the command and right-click on it, then select: Open man Page






              share|improve this answer





























                23














                No, you do not need to know its PID.



                You can use:



                pkill -x Slack


                Or:



                killall Slack



                Note: Be sure to read the manual page for whichever command you choose to use, in order to see the various options available to the command, as may be relevant to its particular usage. In Terminal type e.g. man pkill and press enter, or just type the command and right-click on it, then select: Open man Page






                share|improve this answer



























                  23












                  23








                  23







                  No, you do not need to know its PID.



                  You can use:



                  pkill -x Slack


                  Or:



                  killall Slack



                  Note: Be sure to read the manual page for whichever command you choose to use, in order to see the various options available to the command, as may be relevant to its particular usage. In Terminal type e.g. man pkill and press enter, or just type the command and right-click on it, then select: Open man Page






                  share|improve this answer















                  No, you do not need to know its PID.



                  You can use:



                  pkill -x Slack


                  Or:



                  killall Slack



                  Note: Be sure to read the manual page for whichever command you choose to use, in order to see the various options available to the command, as may be relevant to its particular usage. In Terminal type e.g. man pkill and press enter, or just type the command and right-click on it, then select: Open man Page







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 29 at 0:50

























                  answered Mar 27 at 14:26









                  user3439894user3439894

                  28.6k64665




                  28.6k64665























                      17














                      You can use AppleScript to tell the application to quit:



                      osascript -e 'quit app "Slack"'


                      this will tell the application to quit and will start all the save and cleanup tasks. Or you can send the TERM signal with pkill but it could be that the application will not shut down cleanly



                      pkill -x Slack





                      share|improve this answer




















                      • 6





                        This is the best method, because it replicates what happens when you use File>Quit from the menu.

                        – Barmar
                        Mar 28 at 16:15






                      • 2





                        Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                        – TJ Luoma
                        Mar 30 at 2:58















                      17














                      You can use AppleScript to tell the application to quit:



                      osascript -e 'quit app "Slack"'


                      this will tell the application to quit and will start all the save and cleanup tasks. Or you can send the TERM signal with pkill but it could be that the application will not shut down cleanly



                      pkill -x Slack





                      share|improve this answer




















                      • 6





                        This is the best method, because it replicates what happens when you use File>Quit from the menu.

                        – Barmar
                        Mar 28 at 16:15






                      • 2





                        Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                        – TJ Luoma
                        Mar 30 at 2:58













                      17












                      17








                      17







                      You can use AppleScript to tell the application to quit:



                      osascript -e 'quit app "Slack"'


                      this will tell the application to quit and will start all the save and cleanup tasks. Or you can send the TERM signal with pkill but it could be that the application will not shut down cleanly



                      pkill -x Slack





                      share|improve this answer















                      You can use AppleScript to tell the application to quit:



                      osascript -e 'quit app "Slack"'


                      this will tell the application to quit and will start all the save and cleanup tasks. Or you can send the TERM signal with pkill but it could be that the application will not shut down cleanly



                      pkill -x Slack






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Mar 28 at 21:17

























                      answered Mar 28 at 6:52









                      MatteoMatteo

                      5,317135599




                      5,317135599







                      • 6





                        This is the best method, because it replicates what happens when you use File>Quit from the menu.

                        – Barmar
                        Mar 28 at 16:15






                      • 2





                        Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                        – TJ Luoma
                        Mar 30 at 2:58












                      • 6





                        This is the best method, because it replicates what happens when you use File>Quit from the menu.

                        – Barmar
                        Mar 28 at 16:15






                      • 2





                        Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                        – TJ Luoma
                        Mar 30 at 2:58







                      6




                      6





                      This is the best method, because it replicates what happens when you use File>Quit from the menu.

                      – Barmar
                      Mar 28 at 16:15





                      This is the best method, because it replicates what happens when you use File>Quit from the menu.

                      – Barmar
                      Mar 28 at 16:15




                      2




                      2





                      Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                      – TJ Luoma
                      Mar 30 at 2:58





                      Huh. I've always used osascript -e 'tell application "Slack" to quit' but if the shorter syntax works, then that's obviously preferable. This is definitely a better answer than anything suggesting kill or any of its variants.

                      – TJ Luoma
                      Mar 30 at 2:58











                      12














                      Since I don't yet have the reputation to comment, I'm saying this as a separate answer. pkill without any flags does not match a specific process! For example, running pkill foo would target processes named foo, but would also target processes named foobar. This is because it uses regular expressions.



                      If you wish to kill a specific process, you can pass it the -x flag. For example, pkill -x foo. This will use exact names instead of regular expressions.



                      For example, in your case, pkill -x Slack will do the trick.






                      share|improve this answer

























                      • To turn this into a full answer can you please add the name of the Slack process to kill?

                        – nohillside
                        Mar 29 at 16:48















                      12














                      Since I don't yet have the reputation to comment, I'm saying this as a separate answer. pkill without any flags does not match a specific process! For example, running pkill foo would target processes named foo, but would also target processes named foobar. This is because it uses regular expressions.



                      If you wish to kill a specific process, you can pass it the -x flag. For example, pkill -x foo. This will use exact names instead of regular expressions.



                      For example, in your case, pkill -x Slack will do the trick.






                      share|improve this answer

























                      • To turn this into a full answer can you please add the name of the Slack process to kill?

                        – nohillside
                        Mar 29 at 16:48













                      12












                      12








                      12







                      Since I don't yet have the reputation to comment, I'm saying this as a separate answer. pkill without any flags does not match a specific process! For example, running pkill foo would target processes named foo, but would also target processes named foobar. This is because it uses regular expressions.



                      If you wish to kill a specific process, you can pass it the -x flag. For example, pkill -x foo. This will use exact names instead of regular expressions.



                      For example, in your case, pkill -x Slack will do the trick.






                      share|improve this answer















                      Since I don't yet have the reputation to comment, I'm saying this as a separate answer. pkill without any flags does not match a specific process! For example, running pkill foo would target processes named foo, but would also target processes named foobar. This is because it uses regular expressions.



                      If you wish to kill a specific process, you can pass it the -x flag. For example, pkill -x foo. This will use exact names instead of regular expressions.



                      For example, in your case, pkill -x Slack will do the trick.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Mar 29 at 21:36

























                      answered Mar 27 at 21:59









                      user321134user321134

                      1335




                      1335












                      • To turn this into a full answer can you please add the name of the Slack process to kill?

                        – nohillside
                        Mar 29 at 16:48

















                      • To turn this into a full answer can you please add the name of the Slack process to kill?

                        – nohillside
                        Mar 29 at 16:48
















                      To turn this into a full answer can you please add the name of the Slack process to kill?

                      – nohillside
                      Mar 29 at 16:48





                      To turn this into a full answer can you please add the name of the Slack process to kill?

                      – nohillside
                      Mar 29 at 16:48











                      8














                      You can install htop (via brew for instance).



                      You'll need to run this as root or with sudo. Essentially, it's a text
                      based Activity Monitor.



                      Select the process you want to kill (either with arrow keys or a mouse).



                      Then press k to send the process a signal and then 9 to choose the SIGKILL signal.






                      share|improve this answer















                      We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.


















                        8














                        You can install htop (via brew for instance).



                        You'll need to run this as root or with sudo. Essentially, it's a text
                        based Activity Monitor.



                        Select the process you want to kill (either with arrow keys or a mouse).



                        Then press k to send the process a signal and then 9 to choose the SIGKILL signal.






                        share|improve this answer















                        We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
















                          8












                          8








                          8







                          You can install htop (via brew for instance).



                          You'll need to run this as root or with sudo. Essentially, it's a text
                          based Activity Monitor.



                          Select the process you want to kill (either with arrow keys or a mouse).



                          Then press k to send the process a signal and then 9 to choose the SIGKILL signal.






                          share|improve this answer















                          You can install htop (via brew for instance).



                          You'll need to run this as root or with sudo. Essentially, it's a text
                          based Activity Monitor.



                          Select the process you want to kill (either with arrow keys or a mouse).



                          Then press k to send the process a signal and then 9 to choose the SIGKILL signal.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 29 at 0:42









                          Dancrumb

                          1255




                          1255










                          answered Mar 27 at 17:20









                          BEFioBEFio

                          811




                          811



                          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.




                          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.






















                              6














                              I'm not sure for Slack, but some Applications will run multiple Processes and you may want to kill just one (I find I often need to do this with iTunes, for example). In that case, you can run



                              ps -e | grep -i slack


                              To find all Processes with case-insensitive "slack" in the name. The output should look like (without the header):



                              PID TTY TIME CMD
                              649 pts/1 00:00:00 bash


                              That first column will be your PID. You can then use that to kill specifically that process:



                              kill -9 649


                              Replacing 649 with your PID you found from calling ps.






                              share|improve this answer


















                              • 2





                                kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                                – Matteo
                                Mar 28 at 17:58











                              • Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                                – Carl Witthoft
                                Mar 29 at 14:59






                              • 1





                                @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                                – user3439894
                                Mar 29 at 22:26











                              • So, pgrep is a nice command that combines ps and grip.

                                – Harv
                                Apr 3 at 0:47
















                              6














                              I'm not sure for Slack, but some Applications will run multiple Processes and you may want to kill just one (I find I often need to do this with iTunes, for example). In that case, you can run



                              ps -e | grep -i slack


                              To find all Processes with case-insensitive "slack" in the name. The output should look like (without the header):



                              PID TTY TIME CMD
                              649 pts/1 00:00:00 bash


                              That first column will be your PID. You can then use that to kill specifically that process:



                              kill -9 649


                              Replacing 649 with your PID you found from calling ps.






                              share|improve this answer


















                              • 2





                                kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                                – Matteo
                                Mar 28 at 17:58











                              • Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                                – Carl Witthoft
                                Mar 29 at 14:59






                              • 1





                                @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                                – user3439894
                                Mar 29 at 22:26











                              • So, pgrep is a nice command that combines ps and grip.

                                – Harv
                                Apr 3 at 0:47














                              6












                              6








                              6







                              I'm not sure for Slack, but some Applications will run multiple Processes and you may want to kill just one (I find I often need to do this with iTunes, for example). In that case, you can run



                              ps -e | grep -i slack


                              To find all Processes with case-insensitive "slack" in the name. The output should look like (without the header):



                              PID TTY TIME CMD
                              649 pts/1 00:00:00 bash


                              That first column will be your PID. You can then use that to kill specifically that process:



                              kill -9 649


                              Replacing 649 with your PID you found from calling ps.






                              share|improve this answer













                              I'm not sure for Slack, but some Applications will run multiple Processes and you may want to kill just one (I find I often need to do this with iTunes, for example). In that case, you can run



                              ps -e | grep -i slack


                              To find all Processes with case-insensitive "slack" in the name. The output should look like (without the header):



                              PID TTY TIME CMD
                              649 pts/1 00:00:00 bash


                              That first column will be your PID. You can then use that to kill specifically that process:



                              kill -9 649


                              Replacing 649 with your PID you found from calling ps.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 27 at 18:57









                              scohe001scohe001

                              35239




                              35239







                              • 2





                                kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                                – Matteo
                                Mar 28 at 17:58











                              • Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                                – Carl Witthoft
                                Mar 29 at 14:59






                              • 1





                                @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                                – user3439894
                                Mar 29 at 22:26











                              • So, pgrep is a nice command that combines ps and grip.

                                – Harv
                                Apr 3 at 0:47













                              • 2





                                kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                                – Matteo
                                Mar 28 at 17:58











                              • Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                                – Carl Witthoft
                                Mar 29 at 14:59






                              • 1





                                @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                                – user3439894
                                Mar 29 at 22:26











                              • So, pgrep is a nice command that combines ps and grip.

                                – Harv
                                Apr 3 at 0:47








                              2




                              2





                              kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                              – Matteo
                              Mar 28 at 17:58





                              kill sends a signal to terminate the app. It is not necessary to use -9 (kill) if the application is responding. You risk to loose unsaved data

                              – Matteo
                              Mar 28 at 17:58













                              Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                              – Carl Witthoft
                              Mar 29 at 14:59





                              Similarly, if you did happen to want to kill, say, all 5 instances of some named process, you could filter the output of ps on the CMD value and then kill all the first entries on those lines.

                              – Carl Witthoft
                              Mar 29 at 14:59




                              1




                              1





                              @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                              – user3439894
                              Mar 29 at 22:26





                              @Carl Witthoft, you can simply use killall procname, e.g. killall Slack and it will kill all occurrences of Slack or whatever procname is. No need to use ps!

                              – user3439894
                              Mar 29 at 22:26













                              So, pgrep is a nice command that combines ps and grip.

                              – Harv
                              Apr 3 at 0:47






                              So, pgrep is a nice command that combines ps and grip.

                              – Harv
                              Apr 3 at 0:47




                              -command-line, macos, terminal

                              Popular posts from this blog

                              Frič See also Navigation menuinternal link

                              Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

                              fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox