Do not leak pipe fds

Only create the pipe, if the thread is really started, and use Python
file objects for both sides to let the GC close the pipe if the monitor
is collected.