After #16502 the standardized extension install path now makes available preflight, uninstall, and postflight tasks for scripts to hook. However, as noted in the pull request:
The current implementation triggers both preflight and uninstall immediately, this seems a bit illogical to trigger two hooks back-to-back when nothing else has happened in the middle. I think moving uninstall somewhere in the middle (after SQL and before files is where it is for plugins in 3.x) may make sense, but there may be other options as well.
IMO we should move the uninstall task somewhere later than it is now, otherwise either preflight or uninstall is redundant.