Make the IM to have a safe exit function