I've a U.K. work visa that expires in several months. Can I leave the country the exact day the visa is marked as "valid until"? Or should I depart a day earlier?
You are legally in the UK up to midnight of the expiry date of your visa. If the date is 15 Feb 2014, for example, you have until midnight local time to leave.
Just adding... If something happens and you can't depart, you can soften the effect by reporting to the Border Force (or in their absence, the police). An Immigration Officer is empowered under Paragraph 31 and 31/A to extend, but he doesn't have to if he doesn't want to. The police will slag you off, but at least you tried.
So it's midnight of the expiry date.
Adding: For those interested in the 'grace period', the formal penalties start to kick in at 28 days. Those are absolute and enforceable bans against entry. But even for a time shorter than that, a subsequent application to renew or get a new work permit will be invariably refused on credibility grounds.