Fixed possible double joining of scheduler thread.