gdb may request selection of a dead thread, so check the target first.

Resolves #438.