Add a cancel callback

It's necessary to know when the operation was canceled. Added a cancelFunction callback.