Fix potential crash after unload of func_periodic_hook or test_message.