Desktop Applications

Terminate Process

If you start application using Global.DoLaunch then you can close it using Global.DoKillByPid.

Send Keyboard Shortcut

When application is an active window you can send Alt-F4 key combination to close it.

Global.DoSendKeys('%{F4}');

You can also use any object within application window to send the shortcut.

SeS('_1').DoSendKeys('%{F4}');

Learn Close Button

If you are testing the application via UIAutomation library you can learn Close button and click on it in your test.

Note: this method does not work with Managed library (if you are testing a C# application).

SeS('Close').DoClick();

Web Applications

To close browser window use Navigator.Close.