The following C code allows to simulate the power button press:
(see
http://msdn2.microsoft.com/en-us/library/ms837843.aspx)
// Send keypresses that mean power off
keybd_event(VK_OFF,0,KEYEVENTF_SILENT,0);
keybd_event(VK_OFF,0,(KEYEVENTF_KEYUP|KEYEVENTF_SI LENT),0);
Works fine with my x50v.