Added automatic shutdown feature