Call __destruct on the JS implementation when the instance is destroyed.