Added waitForClose to wait for pidfile to be released.