We can close GP programatically using VBA and Continuum API. Daoud’s article contains the code which we can use: Programatically Closing for Dynamics GP.
This will not close Dynamics GP if there are some background processes being run. The main reason: this is nothing more than simulating a User selecting “Exit” from “Microsoft Dynamics GP” menu, which is a very good thing, as we are not suppose to close GP when some background process is being run.
Having said that, we should pay a visit to David’s article: Running a macro to automatically close GP Example. Now this code also does the same, closes GP programatically, but does it after an important background process (the Check Links in his example) completes its task. We can reuse the logic to any similar requirement. David’s article is there for our reference for sometime now, but I just thought of highlighting this again, as both articles are contextual.
Very useful articles.