Only uninstall signal handlers if they were actually installed (#9068)

Submitted by: tomgr