I doubt the engine switches off because it won't make it as the car has no idea how far to go.
More likely a sensor issue, possibly engine oil level, as this has repeated on the same hill and could force the engine to shut down if it senses that level is dangerously low.