Added code block which cleans buffers and unregister CUDA resources. Unfortunately, works when user presses ESC