Added shut down handling