title: Ctrl-C does not kill my python code due to threading problems
body: <p>I am using Flask as a local server and initiating a new thread: </p>
  
  <pre><code>rospy.init_node('path_planner')
  </code></pre>
  
  <p>As I am initiating this thread on a main thread, when I press Ctrl-C, nothing happens and I have to manually kill the process using kill -9</p>
  
  <p>I have tried to signal_handler but still I was not able to kill my program. </p>
  
  <p>Here is my code for POST method, which is used often:</p>
  
  <pre><code>app = Flask(__name__)
  app.config["MONGO_URI"] = "mongodb://ed:123@ds029227.mlab.com:2325/test"
  
  mongo = PyMongo(app)
  
  @app.route('/goal', methods=['POST'])
  def add_goal():
      goal = mongo.db.goal
      position = request.json['position']
      orientation = request.json['orientation']
      goal_id = goal.insert({'position' : position, 'orientation' : 
  orientation})
      new_goal = goal.find_one({'_id' : goal_id})
      output = {'position' : new_goal['position'], 'orientation' : 
  new_goal['orientation']}
      position_x = json.loads(position['x'])
      position_y = json.loads(position['y'])
  
      return jsonify(output)
  </code></pre>
  
  <p>And here is my main:</p>
  
  <pre><code>if __name__ == '__main__':
      rospy.init_node("path_planner")
      app.run(debug=True)
  </code></pre>
  
  <p>When I run my code, flask server fires up and everything works as expected, POST method does its job. However, when I am done and I need to exit the program, I press Ctrl-C but nothing appears to happen.</p>