Candle-lighting time in my city starts 5 mins after I technically finish work, but it takes me about 15 minutes to drive home from work - sometimes longer if the traffic is bad. Is this a violation of Shabbat? How does one deal with such situations?
The best thing to do, by far, is to work with your boss to rearrange your schedule so you're not cutting it anywhere near that tight.
But for theory's sake, if you somehow find yourself stuck: the most-common practice in North America is to publish candle-lighting times that are 18 minutes prior to sunset. (Among other things, this is to accommodate one minority medieval opinion that Shabbat starts then.) So you have a small window here: if the published candle-lighting time is 7pm, you could technically still drive home and light candles until 7:18pm.
(In some communities the standard published time can be as much as 40 minutes before sunset, by the way.)
Speak to a rabbi (in advance) about what to do if you're still in your car at sunset. (There are a lot of varying details here. For instance, you may be in a sketchy neighborhood where ditching your car and walking could mean risking your life -- or if a joyrider got your car with the keys inside, risking the lives of others.)
Someone angrily wrote to Rabbi Moshe Feinstein -- "Rabbi, I saw you riding in a car to synagogue Friday evening after Shabbat started!" Rabbi Feinstein explained that it was, in fact, during this 18-minute window. However, he wrote, as it seems to be bothering people, he'd rework his schedule and ask his driver to pick him up earlier, to arrive at synagogue at least 18 minutes before sunset. (Note: I think it was actually a yeshiva that had prayers, not a synagogue, but you get the point.)
Strictly speaking, as Shalom wrote, you can probably* rely on the 18 minute "window". Many people do.
I have, whenever necessary, arranged with my employers and/or clients to allow me to leave work at a time deemed (by me) adequate to allow me to commute home and prepare for Shabbath and (deemed by them) adequate to allow me to complete my work. This has typically been 2 hours prior to candle-lighting, give or take a few minutes; to make it easy to keep track, I usually leave at a time ending in multiples of 5 (2:45pm when candle-lighting is at 4:43pm).
To make things even simpler, some people I know leave at a set time every Friday in the winter months, say 2:30pm, regardless of whether candle-lighting is at 4:30pm or 5:30pm.
Some people I know work a 10-hour schedule Monday through Thursday and take off on Friday.
Many countries have laws requiring employers to give religious accommodation to a certain point. CYLA(ttorney).