For a typical retail business, you should definitely be in line to check out by closing time. It should go without saying, but in line should including having your method of payment at hand (not outside in your car) and having selected everything you are planning on buying.
For a restaurant, it's a bit different, since there is the issue of waiting for food you've ordered and then consuming it. I don't think you need to be paying and leaving at exactly closing time, but you should also avoid lingering after closing. Once it's closing time, you should finish your meal, not order another course, and pay your bill and leave. If a restaurant accepts orders up until closing time, then they have to accept that they will need to stay longer for people to finish their food. In the example of ordering a complicated drink just before closing, that seems fine to me, but having to run to your car to get payment, that is definitely rude. If orders end a a certain time, then it will take some time for the staff to clean up, during which time the customer can finish their drink or food. If the intent it for staff to leave at exactly closing time, then the business needs to plan accordingly and not accept orders less than X minutes before closing.
For a Starbucks not to brew a pot of coffee 30 minutes before closing seems problematic unless they post something stating the rule. After all, many customers are coming to Starbucks for coffee, so it's a pretty reasonable thing to expect them to order. It's one thing to limit the menu after a certain time or say that certain items are not available after a certain time, but to cut off one of the key items seems a bit much. For the employee, she's stuck in the middle so there is not point in taking ones frustration out on her. On the other hand, a complaint to the manager or corporate is perfectly fine.