Fix UNIX-specific thread handle leak.