Added shutdown hooks and closing services