Fix cancelling for external thumbnailers.

If we change directory while external thumbnailer is working it still may
stay running so thumbnails loading cannot continue until it finishes,
some logic was incorrect in killing the child.
Since using a lot of global variables isn't good thing to do, the commit
simplifies that pid is known only to thread and thread watches all:
- the child to terminate;
- timeout on generation;
- cancellation from caller.
That can be done easy using broadcast by any of those sources but thread
sleeps in wait until one of those events happens and kills the child if
required.