Clean up imports
Check if timer is closed before closing

If we don't do this, it'll raise an Exception if the timer is already closed.