Condition check before ending the main thread.