There are indeed a whole bunch of security features which prevent a lift from free-falling.
However there is another risk of it flying up and slamming into the ceiling for most types of lifts. For that kind of malfunction there is often no safe guard. A lot of lifts are of the type where they use a large weight which is about half the weight of the maximum load capacity of the lift. This weight is used as a contra weight and hangs in the elevator shaft (so it goes down if the lift goes up). If the brakes in the engine on top of the lift shaft fail there is nothing stopping the contra weight and the lift will fly up.
This is a YouTube video of that happening: https://youtu.be/Ys0rDAxdd-g (warning its not graphic but obviously a disturbing thing to see)
Back in university I had a side job as a security guard in an office building, when this happened. Someone took the cargo elevator, which was built to carry a higher load than the regular elevators, so it had a massive counter weight. The thing slammed into the ceiling with a bang that could be heard through the entire building, and the damage was quite extensive. Took a while for the guy to calm down as well.
in the European Union, nowadays, it is required to have a safeguard for "shooting up" as well[0]. If I recall correctly for quite some time it wasn't though. My Father who works in the elevator industry told me that in the GDR (German Democratic Republic) it was already mandatory but after reunification for some years Germany had more lax regulations til catching up again.
Most freight elevators are like that, though. So while that's a slightly horrifying diagram, a lot of people will have experiences what it's like being in on.
(In German, there's the word "klemmen" = to tuck, get stuck, get trapped, get caught; presumably it's a cognate. So, the above presumably is a Swedish word for "the risk of getting stuck and squeezed".)
My answer also meant to address that :-). I meant: There are plenty of technical ways to implement it (and the parent proposes a good one) but its not mandatory to do so, it costs money, and therefore its simply not implemented most of the time.
Source: documentary on the first elevators