Don't emit thread event twice when explicitly detaching a thread.
Unregister runtime-managed threads before OS cleanup kicks in.

	* mono-threads.c:
	* mono-threads-posix.c: Explicitly detach a thread from the wrapper
	instead of relying on the TLS destructor. This gives a good environment
	most of the time for other parts of the runtime to work with.
On windows, Register/unregister runtime-managed threads from our wrapper.

	* driver.c: Don't auto attach all threads, this is the same behavior of
	posix and mach. We still auto-detach so we can catch foreign threads that
	forgot to do it.

	* mono-threads-windows.c: Detach the thread after the thread fun has run to
	completion, this ensures we cleanup runtime-managed threads in a saner fashion.
Add MonoThreadInfo::runtime_thread so we can know if this thread is managed by the runtime or not.

	* mono-threads.h: Add new field to MonoThreadInfo.

	* threads.c: New API function mono_thread_is_foreign that allows one to query if a given thread
	is foreign or not.
Document the new function and fix a typo on other.