Fixed memory leak

Flask's app context keeps a refence to the app instance. 
Thus, in order to prevent memory leaks the reference app 
context should cleared  on teardown.