[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How to kill my own process

Posted on 2012-09-14
Medium Priority
Last Modified: 2012-09-14
I want to be able, from code, to kill my process.  I just want to blast it out of the water -- just as if I had gone to Task Manager and used "End Process" there.  I've tried some things in my code like


I even wrote code to enumerate all windows open, look for my app's title, and then send that window a WM_CLOSE message.

But I am not killing it.

Now, I know that this must be because it launched some other process that is still active, and I shoudl really figure that out, and do something clean, but.... isn't there a way to definitively KILL myself?   Like Task Manager does.
Question by:tullhead
  • 2
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 38399834
The simplest ways:


// or


Open in new window

LVL 86

Expert Comment

ID: 38399838
Or in a broader sense regarding not only your own process: http://support.microsoft.com/default.aspx?scid=KB;en-us;178893& ("How To Terminate an Application "Cleanly" in Win32")

Author Closing Comment

ID: 38399981
I like simple!


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question