I know the ExitWindowsEx() API function which simply shuts down Windows. But as far as I know, you cannot make Windows install any pending updates with it.
The best you can do is call InitiateShutdown and include the SHUTDOWN_INSTALL_UPDATES flag on Vista and higher. Windows XP does not support programmatically shutting down with updates.