Only rewrite pidfile when reloading was successful.

Refs #6118