As it was struggling to get to the 4th floor, I was technically stuck.
In this event, hit the emergency button. I know, you think you're not supposed to, but HIT THE DAMN BUTTON.
It calls the elevator company immediately to get you out. It is not embarrassing, that is literally what they are there for.
This button also sends a diagnostic signal to the elevator company so that they can immediately troubleshoot what went wrong. You don't hit it, someone may get stuck right after you and they won't know what exactly went wrong.