Yes if your late to the gate the doors will be shut and your bags found and off loaded. All tend to be bar coded at check-in, followed through security and scaned as put into bins or hold. So we know where it is!
Airlines will take the delay to remove the offending bag rather than let you on. Can sell you another ticket and why let you get away with delaying all those pax that got to the gate well in time.