in reply to Controlling a program in Windows

Without knowing what program it is (and whether of not it likes getting told what to do ;), I'd say that you should send the proper keystrokes to make it "Save and Close".

Win32::GuiTest is real easy to use for this...
See Re: Re: TWAIN Issues and Perl for an example of it's usage.