Cleanup API thread if it exits early
diff --git a/main.c b/main.c
index fab46ef..3a9865a 100644
--- a/main.c
+++ b/main.c
@@ -3770,10 +3770,14 @@ static void *workio_thread(void *userdata)
static void *api_thread(void *userdata)
{
+ struct thr_info *mythr = userdata;
+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
api();
+ mythr->pth = 0L;
+
return NULL;
}