Wrap dispose in setTimeout to prevent segfault