If you somehow manage to get on top of the elevator cab (indeed as the sibling comment points out, there is no escape hatch at the top), you will generally see a small control panel with a switch to put it in inspection mode. That turns off autonomous control and from there the cab will stay where it is unless you manually action the up/down switches (assuming the "safety chain" isn't broken - which if the elevator suddenly stops, it may be - so even those won't do anything then).
If you somehow manage to get on top of the elevator cab (indeed as the sibling comment points out, there is no escape hatch at the top), you will generally see a small control panel with a switch to put it in inspection mode. That turns off autonomous control and from there the cab will stay where it is unless you manually action the up/down switches (assuming the "safety chain" isn't broken - which if the elevator suddenly stops, it may be - so even those won't do anything then).