Resolve "Add a shutdown hook that stops the GC if it was not stopped yet"

Closes #1564

See merge request main/Sumatra!1451

sumatra-commit: 13a92640721d73ff8c2df5eaf36e6c178406a478
2 jobs for master in 4 minutes and 16 seconds (queued for 4 seconds)
Status Name Job ID Coverage
  Build
passed build #70593

00:03:11

passed test #70594

00:04:15