How to prevent apps from using WiFi network? I would like to prevents all app except one (which I use it in foreground) to use WiFi network.

The phone is not rooted so the root firewall are not suitable, and also I don't want to use firewall which create VPN connection. 

I have tried how-to-restrict-background-data-for-metered-wi-fi-networks-on-android but when I check the network traffic of the device it contains closed app traffic also.
In the place described on the linked page¹ you can mark selected APs to be dealt with as if they were "mobile networks" – i.e. "background data restrictions" which usually apply to mobile networks only would be applied to those as well.

In order for that to have any effect, you either need to toggle the "background data" setting – or limit background data for those apps which should not use them. The latter can be done in Settings › Data Usage below "mobile data limit", where you first need to set a global limit (can be some "phantom value", i.e. very high). Then walk the apps below that and tick their "limit background data" setting.

I'm not 100% sure what falls into background data – but roughly it should be what an app does without your explicitly telling so. A.o. that's "background syncing" and similar "intervall stuff" – but definitely nothing you'd have to setup manually, like loading a page in your browser.



¹ Nougat (Android 7) and up: Settings › Data Usage › Network Restrictions
  below that: Settings › Data Usage, tap "More" (or the 3-dot overflow-menu) › Restrict Networks