Join threads properly in test.