fix segfault.
add deinit sequence.