call pthread_exit at end of main and dont call halclose