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.
Threads must be joined on scheduler termination and tasks must be pushed onto the stack to allow better memory management.