Fix bug in scheduler and tasks.

Threads must be joined on scheduler termination and tasks must be pushed onto the stack to allow better memory management.
4 jobs from master in 36 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #3180
build_cmake

00:20

 
  Test
failed #3181
run_tests

00:16

 
  Sanitizer
skipped #3183
run_address_sanitizer
skipped #3182
run_thread_sanitizer
 
Test run_tests
                                                                                             ^
app/playground/CMakeFiles/playground.dir/build.make:62: recipe for target 'app/playground/CMakeFiles/playground.dir/main.cpp.o' failed
make[2]: *** [app/playground/CMakeFiles/playground.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:191: recipe for target 'app/playground/CMakeFiles/playground.dir/all' failed
make[1]: *** [app/playground/CMakeFiles/playground.dir/all] Error 2
make: *** [all] Error 2
Makefile:140: recipe for target 'all' failed
./ci_scripts/run_tests.sh: line 9: ./bin/tests: No such file or directory
ERROR: Job failed: exit code 1