Fix segfault when calling hash_final twice

context is freed in hash_final. The second call tries to use the freed variable.

Fixes #3741