# Use of rospy.on\_shutdown()

**URL:** <https://get-help.theconstruct.ai/t/use-of-rospy-on-shutdown/2873>\
**Category:** ROS Basics In 5 Days (Python)\
**Created:** [April 2, 2020, 3:46am UTC](https://get-help.theconstruct.ai/t/use-of-rospy-on-shutdown/2873 "2020-04-02T03:46:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [April 2, 2020, 7:33am UTC](https://get-help.theconstruct.ai/t/use-of-rospy-on-shutdown/2873/2 "2020-04-02T07:33:17Z")

</div>

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](https://get-help.robotigniteacademy.com/t/how-to-stop-your-robot-when-ros-is-shutting-down/225).

---

_[View the full topic](https://get-help.theconstruct.ai/t/use-of-rospy-on-shutdown/2873)._
