Exit when an exception occurs.
Use time instead of datetime to get timestamp.