SCTX-1334

Fix a number of shutdown related issues