First, yes, USCIS does know when you leave the US. How you may ask? Well, whenever you as a foreigner buy a ticket, that information is sent to the Customs and Border Protection agency (CBP). CBP then sends the information to USCIS. This is displayed on one screen in the USCIS computer system that the officer in charge of your case can access. Once you actually board the plane, the system is again updated and the officer, by drilling down into the system can verify that fact as well as the date, etc.
This all came to light for many recently when USCIS began denying many application stating that the persons who filed the application had abandoned the application by leaving the US while it was pending (for changes of status and the adjustment of status applications, you need to remain in the US while they are pending or they can be considered abandoned). USCIS was basing this off that preliminary screen showing that a ticket had been purchased. Unfortunately the officer failed to drill down to see if the person actual used the ticket and boarded the plane, etc.
If you received such a denial, you should consult and attorney so that they can remedy the situation.
Please remember, as always, this blog does not offer legal advice. If you need legal advice, consult with a lawyer instead of a blog. Thank you.