main: Fix possible crash when sensor disappears

When the sensor disappears, we get a read error within the
prepare_output() callback. But as we assign the retval of that function
to an OrientationUp value, we lose the signedness and never see the
error.

Instead, assign the retval to an integer that we can check correctly,
and only assign to an OrientationUp value once we've checked for errors.
main: Really exit when the sensor disappears

When the sensor disappears, we only stopped polling the accelerometer
for new values. This wasn't enough to actually exit cleanly.