I've just started using Delphi and right away there's one thing I can't do in a VCL forms application: destroy it properly.

At the moment I'm calling Form1.Destroy which appears to work, but if I look at the processes list it's still there and Delphi refuses to write the .exe while it is.

How do I properly destroy it?

destroying the form will not end the application.
Use application.terminate to do that.
That will also destroy any remaining objects at the same time, releasing (or it should) all application memory.

But what do you mean by "Delphi will not write the exe"? Sounds like you are having some serious misunderstanding about how Delphi works.

Hi,

Use Application.Terminate; as suggested by previous post (or Halt; ). Never call ___.Destroy; call ___.Free; to release an instance of an object that you created.

Loren Soth

This may be old but to anyone who finds this thread the Application.Terminate method is not the recommended way to close your application.

While it will force your application to terminate it will skip the normal unallocation processes which Delphi kindly does for you using the recommended techniques.

The recommended way to close your application is to close the applications main form.

This can be done in the code by using FormName.Close; or by the user closing the form with the X button / pressing Alt-F4 etc. Application.Terminate will simply force the applications thread to be halted, thereby not properly freeing any resources allocated by the application.

This article has been dead for over six months. Start a new discussion instead.