There are usually other factors at play when they pick a minor item as reason for dismissal. I don't know about your case, but what usually happens is there are other problems that don't warrant firing all by themselves. It could be attitude, job performance, attendance or even hygiene.
Many managers don't like having to confront people about personality or performance problems. It's just an unpleasant thing to do. So they put up with stuff till some little thing pushes them over the edge. I hate that aspect of beinga manager.
In this case, the manager may have figured that you could have called a cab. 5 miles is less than $10 in most areas. Going off shift early may have casued problems for others in the company. It may have cost the company money. It's hard to tell.
In many cases, you can talk to your manager, ask what areas need improvement and keep the job. That's assuming that you want to keep the job and are mature enough to handle the possible criticism.
Seems like rambling. I'll stop now.
Daniel