Close tabs automatically with Python