Create an event procedure
Event Properties
Events and Event Properties Reference
Find out when events occur
Terminate Event