fix(library/module): potential deadlock when child thread threw an exception

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>