Add docstring to session decorator
Refactor creating of temp file
Remove unnecessary searching a view in terminate()