Windows: Avoid calling RegCloseKey on an invalid handle.