Added a shutdown function