[doc,library-ref] Provide an example of finalization.

Fixes #583.