& at the end of your second command tells Linux to run this command in the background. You can see a list of background commands with $ jobs . Ubuntu16.04 example:
$ sudo Xvfb :10 -ac & [1] 31294 $ jobs -l [1]+ 31294 Running sudo Xvfb :10 -ac &
As you can see in the above, jobs -l shows the background job, and the second output column is the PID , which can be used to destroy it like $ sudo kill 31294 .
Another option, which may be cleaner, is to run Xvfb just to run the command you want and exit automatic mode instead of keeping it in the background. So you replace your lines 2,3 and 4 with:
xvfb-run python my_selenium_tests.py
Just replace python my_selenium_tests.py any test run method. It will open Xvfb just for that and will close at the end.
source share