fixed some threading stuff

Make sure not to start several main threads and make sure to close the
child once properly.