Fixed issue: cleanup() function not call in onerror handler.

Calling error() function raise exception and prevent cleanup() calling.