Caveat, last bar can be received while time slot not completed. You must be ready for this case,
BTW you can ask for live update of last bar and get end of slot when see firing historicalDataEnd
http://interactivebrokers.github.io/tws-api/historical_bars.html#hd_request