If you are not closing connections then obviously this would cause database to eventually crash. A restart will flush all connections that is why you server is probably restarting.
So fix your application and close connections. In the meanwhile you can have this script to kill the opened connections staying dead in your process-list. The script will kill everything that is stalled in the processlist for 500 sec. You may change the time as per need basis.
SECONDS_TOO_LONG=500
QUERIES_RUNNING_TOO_LONG=`/mysql/bin/mysql -u user -p'password' -ANe"SELECT COUNT(1) FROM information_schema.processlist WHERE user<>'system user' AND time >= ${SECONDS_TOO_LONG}"`
if [ ${QUERIES_RUNNING_TOO_LONG} -gt 0 ]
then
KILLPROC_SQLSTMT="SELECT GROUP_CONCAT(CONCAT('KILL QUERY ',id,';') SEPARATOR ' ') KillQuery FROM information_schema.processlist WHERE user<>'system user' AND time >= ${SECONDS_TOO_LONG}"
/mysql/bin/mysql -u user -p'pass' -ANe"${KILLPROC_SQLSTMT}" | /mysql/bin/mysql -u user -p'pass'
fi;