first pass at shutdown middleware