Tidying up function shudown

handles edge case when server is already running