We need to close all handles to ensure that all logging threads are
joined.
Care must be taken to close the writing end of the logging pipe first so
that the logging thread can issue a final ReadFile() call. Before the
thread exits it should close the reading end, however as a safety
measure we WaitForSingleObject() then close the reading end from the
main rotation thread.