Switched shutdown to try-finally block to allow returning while exiting.