Welcome to the 'bolt!!

The knocking and banging going on before your engine quit would cause me to suspect something in the valve train, maybe a bent pushrod, stuck valve, broken lifter or something like that caused the cam to eventually bind up and then the gear sheared. Inspect everything thoroughly before you button it back up.

Good luck.