Add regression test for thread disable memory leak.