Fixed error on shutdown