Fix pidfile to close upon failure.