I am currently working on an application ROFFLE, I may not be very good in terming correctly, What I am able to do right now? 
User goes on a website, he clicks on a button and an ajax request is done to python file (test.py) but when he exits, the request is aborted and the processing done till yet has gone waste
What I want to do? 
As user clicks the button, the processing starts. The script should not be killed even if the user leaves the webpage. In simple words, the Javascript part should be limited to trigger/queue the python script to execute (with input provided online) which has to be deployed by a web server that supports it via CGI
How can this be implemented?
Please note:
1. This is a web application and cannot be a software
From the question I read that you have already managed to run a Python script in a web server via CGI and you already know how to do an HTTP (ajax) request from your JavaScript to that web service. 
When you now close the page in your browser (or an excavator cuts your line), the backend python script is not terminated. In fact, how should the backend even know that you have closed the page? Your Python script is still running in the backend, but no one will be left to capture the HTTP response of the web server and display it to you.
However, when you want to start some kind of demon, a program that is supposed to run in the backend for a very long time, then your Python script should spin off that task via a Popen in a variant that keeps the child process alive, even when the script has returned it's HTTP response (and possibly even the web server has shut down).
This pattern is sometimes used to remote control little servers that mock IoT devices in test environments. Just start and stop the simulation via some fire-and-forget HTTP requests triggered from a simple interactive web page.
Asynchronous unblocked Execution/triggering of python script through javascript