Use of rospy.on_shutdown()

Hi @prajwalthakur98,

Thanks for asking and welcome to the Community!

rospy.on_shutdown() allows you to specify a function that should be called when ROS has initiated a shutdown (when you press Ctrl + C or the program is ending normally).

This could be used for various purposes, for example, you might want to stop your robot if ROS is shutting down. See an example here: How to stop your robot when ROS is shutting down.