Automatically closing an MS Dos Window?

One of the things my program does is execute MS DOS programs at times. I
use the CreateProcess API call and it all goes fine.

The problem which I am having is that when the program has completed
execution, the Window remain open and is only closed when the used clicks
on the X in the upper right corner or through the system menu.

Is it possible to set the process to automatically close the window when
the MS DOS program has completed execution?

I have seen that this setting can be set since the Properties for the
standard MS-Dos Prompt in the Win95 program menu has a checkbox to close
the window on program completion.

Any tips or suggestions would be very welcome!

Taquin Ho
taquin...@itot.sifogroup.se