The Terminate() method is run after AutoCAD closed (that's why I said it "never occurs in AutoCAD").
As dgorsman said, it can be use to release external resources, close a connection to a database...
I cannot say why the TEST command is unknown for you (it works fine here).
You can try to remove the ExtensionApplication attribute after the using directives ("This line is not mandatory, but improves loading performances").
Or add a CommandClass one pointing on a Commands class which may contain the commands methods (this can be prefereably done in a separate file or in the same one as below):
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Windows.Forms;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
// These lines are not mandatory, but improve loading performances
[assembly: ExtensionApplication(typeof(ExtensionApplicationTest.TestApp))]
[assembly: CommandClass(typeof(ExtensionApplicationTest.Commands))]
namespace ExtensionApplicationTest
{
public class TestApp : IExtensionApplication
{
public void Initialize()
{
MessageBox.Show("Initialize", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
AcAp.Idle += OnIdle;
}
void OnIdle(object sender, EventArgs e)
{
AcAp.Idle -= OnIdle;
MessageBox.Show("Idle", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public void Terminate()
{
MessageBox.Show("Terminate", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
public class Commands
{
[CommandMethod("Test")]
public void justTest()
{
MessageBox.Show("Just a simple test.");
}
}
}