Wrote simple while_shutdown function.