You are perhaps mistaken in being able to perform the gesture with an Apple Pencil...
The Apple Pencil (regardless of being the Apple Pencil Pro, USB-C Pencil, or earlier first or second generation Pencils) do not replicate all the gestures that can be performed with a finger or a passive stylus.
The up-swipe from the bottom edge of the screen - to reveal the Dock, the Task Switcher, or to close an open App - cannot [and has never been possible to] be performed with an Apple Pencil. As such, this screen touch-gesture is performed using a finger.
You can find additional information here:
The iPad User Guide is a rich source of frequently overlooked information about your iPad and iPadOS. The Guide is available online using a web browser (such as Safari):
iPad User Guide - Apple Support
Unless an App is malfunctioning, it is usually unnecessary to fully close an App. Unless an App is actively running in the foreground, the App will be using almost no system resources.
Apps are generally in one of four states - the first three are the most relevant.
- The App is “Active” - it is running running in the foreground. When you switch tasks, the App will continue to run in active state for some minutes before its resources are released and is placed into an Inactive state.
- The App is “Inactive” but remains loaded in [fast] RAM. In this state, the App can be instantly restored to an Active state - but is not consuming CPU or other resources whilst in the inactive state.
- The App is “Inactive” and unloaded. In this state, the App has been completely offloaded (releasing RAM for use by other processes) but its running state has been saved to [slow] flash memory. Returning to an App in this state will cause the App’s saved state to be reloaded from flash memory into Active RAM - without the need to re-initialise the App.
- The App has been closed. All running data has been expelled - there is no “saved” state; relaunch will reload and re-initialise the App from scratch.
Memory management is generally a juggling act - and for the most part, you should allow the OS to manage its memory space. Re-initialising an App is the slowest and most power hungry method of launching an App. Inactive Apps do consume some system resources, but by design, the required system resources to maintain this state are insignificant.
Force-closing an App releases all resources. Whilst the mechanism exists to do so (and in rare circumstances manual intervention to terminate an App may be necessary), a force close reduces system performance.