Fix race condition during shutdown causing a NPE.

From the getThreadGroup() Javadoc:
	Returns the thread group to which this thread belongs.
	This method returns null if this thread has died (been stopped).
Merge pull request #120 from jhermann/master

Fix race condition during shutdown causing a NPE.