You may also want to read the documentation on remove and type deletable setting. When deleting the beforedelete and ondelete callbacks are triggered.