As far as I can see from the code XBoard should exit when the engine dies (which should be a reliable way to disconnect!), unless it happens during the first load of the engine. (This would make it switch to -ncp mode.) But it could be that this is delayed by an error popup, to the point where the user closes that popup. So when running unattended the option 'Popup Exit message' (in the General Options dialog) should be unticked. Was this the case?