Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 221245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:00:55+00:00 2026-05-11T19:00:55+00:00

Sometimes application can’t exit when I called Application.Shutdown , the UI was closed, but

  • 0

Sometimes application can’t exit when I called Application.Shutdown, the UI was closed, but the process is still running. how to shutdown application with close all threads? does the Environment.Exit() could close all thread? or we should call Win32 API TerminateThread to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:00:55+00:00Added an answer on May 11, 2026 at 7:00 pm

    Environment.Exit() is a more brutal way of closing down your application, yes. But in general, if you need to kill your application to make it close then I think you’re looking at the problem in the wrong way.
    You should rather look into why the other threads aren’t closing gracefully.

    You could look into the FormClosing event on the main form and close down any resources that are hanging up the application, preventing it from closing.

    This is how I have found resources hanging up the app.

    1. In debug mode, enable showing of threads. (This will allow you to see all the threads your application is running.)
    2. Close the application in the way that it does not close correctly.
    3. Press pause in Visual studio.
    4. Look at the threads list, and click on them to see where is the code they are hanging. Now that you can see what resources are blocking your application from closing, go to your FormClosing event and close/dispose them there.
    5. Repeat until the app closes correctly 🙂

    Be aware that the threads list in debug mode will show some threads that are run but not under your control. These threads rarely have a name and when you click on them you get a message saying you have no symbols. These can be safely ignored.

    One of the reasons for making sure your application is closing gracefully is that some resources (let’s say a FileStream) are not done working, so using some API to force it to quit can make all sorts of “random” problems come in, like settings/data files not being written and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need the body and html elements to have 100%… May 12, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer OK they have great support at authorize.net and an excellent… May 12, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer Bracketing out your several, larger design questions, I can offer… May 12, 2026 at 12:30 am

Related Questions

Sometimes application can't exit when I called Application.Shutdown , the UI was closed, but
My application sends SMS messages to people, but the numbers entered in as their
I'm currently trying to build an application that inherently needs good time synchronization across
I've got a shared class ( static in C#) which mostly carries some settings
Sometimes it's necessary to modify Windows registry settings during an application install. I've recently

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.