native: optionally exit() after last thread has ended

Used when compiled with NATIVE_AUTO_EXIT defined.
Merge pull request #972 from kaspar030/native_exit_after_last_task_v2

Make native exit after last thread has ended