core: wait for detached threads at application::join()

If application::join() didn't wait for all threads to terminate
(including the detached ones) OSv may start shutting down before
the application object is destroyed (each thread keeps reference to
it).

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>