shared: Improve callback cleanup

Free callback structures when cleanup is called and reap timed out
callbacks in more places.
test: Fix leaking memory in fuzzing