Fix failure handling for thread creation