Fixed an issue causing a jvm crash on detaching the native thread.